<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>linux | 学习笔记</title><meta name="author" content="lzoxun"><meta name="copyright" content="lzoxun"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="基础简介 安装国内阿里云镜像 7 iso 安装国内阿里云镜像 安装国内搜狐镜像  系统12345678910111213141516171819202122232425262728293031323334353637383940414243-   虚拟机    -   快照：保持当前状态，后期玩坏了随时可回到这里    -   克隆：完全克隆与连接克隆，链接克隆相当于创建一个子系统，只要父系统没事">
<meta property="og:type" content="article">
<meta property="og:title" content="linux">
<meta property="og:url" content="http://example.com/2023/07/22/linux/linux/index.html">
<meta property="og:site_name" content="学习笔记">
<meta property="og:description" content="基础简介 安装国内阿里云镜像 7 iso 安装国内阿里云镜像 安装国内搜狐镜像  系统12345678910111213141516171819202122232425262728293031323334353637383940414243-   虚拟机    -   快照：保持当前状态，后期玩坏了随时可回到这里    -   克隆：完全克隆与连接克隆，链接克隆相当于创建一个子系统，只要父系统没事">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png">
<meta property="article:published_time" content="2023-07-22T07:14:09.682Z">
<meta property="article:modified_time" content="2023-07-22T07:14:09.682Z">
<meta property="article:author" content="lzoxun">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="http://example.com/2023/07/22/linux/linux/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"top_n_per_article":1,"unescape":true,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"bottom-left"},
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'linux',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-07-22 15:14:09'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          const now = new Date()
          const hour = now.getHours()
          const isNight = hour <= 6 || hour >= 18
          if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
          else if (t === 'light') activateLightMode()
          else activateDarkMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><script>(()=>{
  const $loadingBox = document.getElementById('loading-box')
  const $body = document.body
  const preloader = {
    endLoading: () => {
      $body.style.overflow = ''
      $loadingBox.classList.add('loaded')
    },
    initLoading: () => {
      $body.style.overflow = 'hidden'
      $loadingBox.classList.remove('loaded')
    }
  }

  preloader.initLoading()
  window.addEventListener('load',() => { preloader.endLoading() })

  if (false) {
    document.addEventListener('pjax:send', () => { preloader.initLoading() })
    document.addEventListener('pjax:complete', () => { preloader.endLoading() })
  }
})()</script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">108</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header"><nav id="nav"><span id="blog-info"><a href="/" title="学习笔记"><span class="site-name">学习笔记</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">linux</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-07-22T07:14:09.682Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-07-22T07:14:09.682Z" title="更新于 2023-07-22 15:14:09">2023-07-22</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="linux"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="基础简介"><a href="#基础简介" class="headerlink" title="基础简介"></a>基础简介</h2><ul>
<li>安装<a target="_blank" rel="noopener" href="http://mirrors.aliyun.com/centos/">国内阿里云镜像</a> <a target="_blank" rel="noopener" href="http://mirrors.aliyun.com/centos/7/isos/x86_64/">7 iso</a></li>
<li>安装<a target="_blank" rel="noopener" href="http://mirrors.aliyun.com/ubuntu-releases/20.10/">国内阿里云镜像</a></li>
<li>安装<a target="_blank" rel="noopener" href="http://mirrors.sohu.com/">国内搜狐镜像</a></li>
</ul>
<h3 id="系统"><a href="#系统" class="headerlink" title="系统"></a>系统</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line">-   虚拟机</span><br><span class="line">    -   快照：保持当前状态，后期玩坏了随时可回到这里</span><br><span class="line">    -   克隆：完全克隆与连接克隆，链接克隆相当于创建一个子系统，只要父系统没事，子系统就能随便搞</span><br><span class="line">    -   重建：安装系统的目录下有一个 vmdk 文件，如果保持好，其他系统安装的时候选择现有磁盘，再选择这个 vmdk 文件，那么系统就能还原</span><br><span class="line">-   <span class="title class_">Linux</span> 发行版(<span class="title class_">Ubuntu</span>、<span class="title class_">CentOs</span>;同一个内核在市场上有三百多个发行版),在 <span class="title class_">Linux</span> 内核上安装软件上</span><br><span class="line"></span><br><span class="line">    -   红帽(<span class="title class_">RedHat</span>)系列</span><br><span class="line">        -   红帽企业版 收费</span><br><span class="line">        -   <span class="title class_">CentOs</span> 相当于免费红帽企业版系统，后期也被红帽公司收购了</span><br><span class="line">    -   debian 系列</span><br><span class="line">        -   <span class="title class_">Ubuntu</span>(在 <span class="title class_">Debian</span> 上二次开发的系统，图形界面效果好)</span><br><span class="line"></span><br><span class="line">-   <span class="variable constant_">GNU</span> 计划：崇尚代码开源</span><br><span class="line">-   <span class="title class_">Shell</span>：指用户界面，包括图形界面（<span class="variable constant_">GUI</span>）和字符界面（<span class="variable constant_">CLI</span>），<span class="title class_">Linux</span> 以字符界面为主，所以字符界面称为是<span class="string">`Shell`</span></span><br><span class="line"></span><br><span class="line">    -   通过字符界面操作的指令叫做 shell 指令（cat /etc/shells）查看 <span class="title class_">Shell</span> 目录</span><br><span class="line">    -   <span class="title class_">Linux</span> 默认使用的是目录中的 <span class="string">`/bin/bash`</span>(通过 echo $SHELL 可以查看)</span><br><span class="line">    -   进入图形界面： <span class="string">`ctrl+alt+f1`</span></span><br><span class="line">    -   进入字符界面： <span class="string">`ctrl+alt+f2~6`</span> ,打开五个字符 <span class="title class_">Shell</span>(<span class="string">`虚拟终端 tty`</span>)</span><br><span class="line">    -   通过远程连的终端： 伪终端<span class="string">`pts`</span></span><br><span class="line">    -   <span class="string">`tty`</span>指令查看当前终端设备文件</span><br><span class="line"></span><br><span class="line">    -   echo 查看$变量值</span><br><span class="line">    -   shell 通常有<span class="string">`自带`</span>一些命令称为<span class="string">`内部命令`</span>如 cd、pwd,但是大多数都是<span class="string">`外部命令`</span>,通过 <span class="string">`stype cd`</span> 查看</span><br><span class="line">    -   外部命令 (<span class="string">`which ls`</span>通过 which 查看指定命令位置)</span><br><span class="line">        -   每个外部命令都对应一个可执行文件，存在系统中</span><br><span class="line">        -   普通命令:<span class="regexp">/bin、/u</span>sr/bin、/usr/local/bin</span><br><span class="line">        -   管理员命令:<span class="regexp">/sbin、/u</span>sr/sbin、/usr/local/sbin</span><br><span class="line"></span><br><span class="line">-   终端：通常把一套键盘鼠标显示屏这样的输入输出设备叫做<span class="string">`终端`</span></span><br><span class="line">    -   笔记本这样的叫做<span class="string">`物理终端`</span>，一个设备只有一个</span><br><span class="line">    -   通过各种软件打开的字符界面叫<span class="string">`虚拟终端`</span>可以很多个</span><br><span class="line">    -   tty ： 查看当前使用终端的名称</span><br><span class="line">-   远程工具</span><br><span class="line">    -   <span class="title class_">Xshell</span>：通过远程 <span class="title class_">Linux</span> 的 ip，连接到远程</span><br><span class="line">        -   必须能 ping 通的才行</span><br><span class="line">        -   win10 默认不让其他人 ping 的，要去防火墙入站规则中设置</span><br><span class="line">        -   拥有账户</span><br><span class="line">    -   <span class="variable constant_">XMANAGER</span></span><br><span class="line">-   命令提示符：[lzoxun@bogon ~]$ --&gt; <span class="string">`[用户名@计算机名 所在目录]`</span></span><br><span class="line">    -   ~ ：指用户家目录，每个用户都不一样</span><br><span class="line">    -   $ ：普通用户</span><br><span class="line">    -   \# ：root 用户</span><br></pre></td></tr></table></figure>

<h2 id="指令"><a href="#指令" class="headerlink" title="指令"></a>指令</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">-   格式 ： 命令 + [选项] + [参数]</span><br><span class="line">-   参数 ： 命令要<span class="string">`处理的对象`</span></span><br><span class="line">-   选项 ： <span class="string">`调节`</span>命令的具体功能，带 - 前缀</span><br><span class="line">-   tab 补全目录| ；多个命令用分号隔离</span><br></pre></td></tr></table></figure>

<h3 id="基本操作命令"><a href="#基本操作命令" class="headerlink" title="基本操作命令"></a>基本操作命令</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line">-   <span class="string">`pwd`</span> ：查看当前所在路径</span><br><span class="line">    -   <span class="string">`-P`</span>: 对于软连接文件 显示真实所在的路径 并非快捷方式的路径</span><br><span class="line">-   <span class="string">`su &lt;user-name&gt;`</span> ： 切换用户</span><br><span class="line">-   <span class="string">`passwd &lt;user-name&gt;`</span> ：更改用户密码（需要交互）</span><br><span class="line">    -   <span class="string">`echo &#x27;123&#x27; | passwd --stdin &lt;user-name&gt;`</span>：直接设置</span><br><span class="line">-   <span class="string">`ln`</span>: ln -s 源文件 快捷方式文 件</span><br><span class="line">    -   源文件路径最好用绝对路径</span><br><span class="line">-   <span class="string">`alias`</span>: 创建别名(<span class="string">`/home/xxx/.bashrc`</span>)</span><br><span class="line">    -   <span class="string">`alias`</span>:查看系统中存在的别名</span><br><span class="line">    -   <span class="string">`alias xxx =&#x27;cat /etc/passwd&#x27;`</span> : xxx 的作用就是查看 passwd</span><br><span class="line">    -   <span class="string">`unalias xxx`</span>:撤销指定别名</span><br><span class="line">-   <span class="string">`history`</span>：</span><br><span class="line">    -   <span class="string">`-d num`</span>:删除指定历史指令</span><br><span class="line">    -   <span class="string">`!num`</span>:执行指定历史指令</span><br><span class="line">    -   <span class="string">`!!`</span>:执行指上一次命令</span><br><span class="line">    -   <span class="string">`-c`</span>:清除缓存的历史命令</span><br><span class="line">-   <span class="string">`man`</span> :查看帮助（help xxx 这里的 xxx 只能是内部指令）</span><br><span class="line">-   <span class="string">`clear|Ctrl+l`</span>:清除屏幕</span><br><span class="line">-   标准输入输出</span><br><span class="line">    -   <span class="string">`Stdin`</span>:标准输入，文件面描述符号 <span class="number">0</span>,鼠标键盘</span><br><span class="line">    -   <span class="string">`Stdout`</span>:标准输出，文件面描述符号 <span class="number">1</span>，显示器</span><br><span class="line">    -   <span class="string">`Stderr`</span>:错误输出，文件面描述符号 <span class="number">2</span>，显示器</span><br><span class="line">    -   重定向</span><br><span class="line">        -   输入重定向 <span class="string">`&gt;`</span> 或 <span class="string">`&gt;&gt;`</span>,将输出到屏幕的内容转到指定文件中</span><br><span class="line">            -   <span class="string">`cat 1.txt 2.txt &gt; 3.txt`</span> :合并文件 <span class="number">1</span> 与文件 <span class="number">2</span></span><br><span class="line">            -   <span class="string">`cat &gt; 4.txt`</span>:编辑文件，回车进入输入模式，ctrl+d结束保存数据</span><br><span class="line">        -   错误信息从定向 <span class="string">`2&gt;`</span> ;将错误信息从定向到指定文件</span><br><span class="line">            -   <span class="string">`cmd xxxxxx 2&gt; filepath`</span></span><br><span class="line">            -   <span class="string">`cmd xxxxxx 2&gt; /dev/null`</span> :将错误信息不存储不打印</span><br><span class="line">        -   <span class="string">`&amp;&gt;`</span> 错误和正确的全部从定向</span><br><span class="line">        -   输出重定向 <span class="string">`&lt;`</span> 或 <span class="string">`&lt;&lt;`</span> ,将键盘的输入重定向到指定文件，详单与查看文件内容如：cat</span><br><span class="line">            -   <span class="string">`cat &gt; /etc/passwd`</span></span><br><span class="line">            -   <span class="string">`cat &gt;&gt; xxx`</span>:进入一个输入模式，无限输入，输入 xxx 后生成文件，结束此状态</span><br><span class="line">-   查找指令已经相关文件位置</span><br><span class="line">    -   <span class="string">`whereis`</span>,<span class="string">`where`</span>,<span class="string">`which`</span></span><br></pre></td></tr></table></figure>

<h3 id="文件操作"><a href="#文件操作" class="headerlink" title="文件操作"></a>文件操作</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br></pre></td><td class="code"><pre><span class="line">-   <span class="string">`cd`</span> ：进入</span><br><span class="line">    -   <span class="string">`cd -`</span> ：进入之前所在目录</span><br><span class="line">-   <span class="string">`ls`</span>：查看目录的文件</span><br><span class="line">    -   <span class="string">`-l`</span> ：查看详细信息</span><br><span class="line">    -   <span class="string">`-a`</span> ： 查看所以文件包括隐藏文件</span><br><span class="line">    -   <span class="string">`-d`</span> ： 查看目录<span class="string">`自己的`</span>信息</span><br><span class="line">    -   <span class="string">`-h`</span> ： 以 k、M 格式显示文件大小</span><br><span class="line">    -   <span class="string">`-R`</span> ：当前目录为根节点，列出所有子节点</span><br><span class="line">    -   <span class="string">`-i`</span> : 查看文件唯一编号 inode</span><br><span class="line">    -   <span class="string">`--help`</span> ：单词一般都有两个杠</span><br><span class="line">-   <span class="string">`touch &lt;file-name&gt;`</span>：创建空文件</span><br><span class="line">-   <span class="string">`mkdir &lt;name1&gt; &lt;name2&gt;`</span>：创建空文件夹</span><br><span class="line">    -   <span class="string">`-p a/b/c`</span> ：创建多级目录</span><br><span class="line">-   <span class="string">`rmdir &lt;name1&gt;`</span>： 删除空目录</span><br><span class="line">-   <span class="string">`rm &lt;file-name&gt;`</span>： 删除文件</span><br><span class="line">    -   <span class="string">`-f`</span>：直接删除</span><br><span class="line">    -   <span class="string">`-r`</span>：删除目录</span><br><span class="line">    -   <span class="string">`-rf`</span>：强制删除目录下所有文件与文件夹</span><br><span class="line">    -   <span class="string">`find * | grep -v 1.txt | xargs rm`</span>：删除指定文件外的所有</span><br><span class="line">    -   <span class="string">`find * | grep -v &#x27;\(1.txt\|2.txt\)&#x27; | xargs rm`</span></span><br><span class="line">-   <span class="string">`cp &lt;old-file&gt; &lt;new-file&gt; `</span>： 复制文件(<span class="keyword">new</span>-file 有-复制，无-改名)</span><br><span class="line">    -   <span class="string">`-r`</span> ：复制目标可以是目录</span><br><span class="line">    -   <span class="string">`-p`</span> ：保留复制目标文件属性</span><br><span class="line">-   <span class="string">`rsync &lt;old-file&gt; &lt;new-file&gt; `</span></span><br><span class="line">    -   <span class="string">`-r`</span>:递归复制子目录</span><br><span class="line">    -   <span class="string">`-v`</span>:查看复制的文件</span><br><span class="line">    -   <span class="string">`-u`</span>：只复制修改过的文件</span><br><span class="line">-   <span class="string">`mv &lt;old-file&gt; &lt;new-file&gt; `</span>： 剪切（剪切目录不要 -r）</span><br><span class="line">    -   安装 mmv</span><br><span class="line">    -   <span class="string">`mmv &#x27;_._._._&#x27; &#x27;#1.#2&#x27;`</span></span><br><span class="line">    -   <span class="string">`mmv &#x27;file\*.rar&#x27; &#x27;text#1.zip&#x27;`</span></span><br><span class="line">    -   #<span class="number">1</span> 代表第一个<span class="string">`*`</span>号匹配的内容，#<span class="number">2</span> 代表第二个*号代表的内容</span><br><span class="line">-   <span class="string">`dd if=/dev/zero of=/tmp/test bs=1M count=60`</span>:构造一个 <span class="number">60</span> 个 1M 大小的文件，从/dev/zero 文件放到/tmp/</span><br><span class="line">-   文件属性设置</span><br><span class="line"></span><br><span class="line">    -   文件或者目录设置扩展属性后 root 也要按照规则操作</span><br><span class="line">    -   <span class="string">`chattr [-RV] +或- i或a 文件`</span></span><br><span class="line">        -   <span class="string">`-R`</span>:递归修改文件夹子目录文件</span><br><span class="line">        -   <span class="string">`-V`</span>: 显示指令执行过程</span><br><span class="line">        -   <span class="string">`+-`</span>:添加或删除</span><br><span class="line">        -   <span class="string">`i`</span>:只读属性，添加后 root 也无法修改</span><br><span class="line">        -   <span class="string">`a`</span>:只能往文件中增加内容，不允许删除</span><br><span class="line">        -   <span class="string">`s`</span>：彻底删除文件，不可恢复</span><br><span class="line">    -   <span class="string">`lsattr 文件`</span>:查看属性</span><br><span class="line"></span><br><span class="line">-   文件查找</span><br><span class="line"></span><br><span class="line">    -   <span class="string">`locate &lt;file name&gt;`</span>:返回文件所在路径,根据索引数据库查找，一段时间后数据库自动更新</span><br><span class="line">    -   <span class="string">`find`</span>: find &lt;查找起始路径&gt; &lt;选项&gt; &lt;查找条件&gt; &lt;处理动作&gt;</span><br><span class="line">        -   <span class="string">`起始路径`</span>:</span><br><span class="line">        -   <span class="string">`选项`</span>:</span><br><span class="line">            -   <span class="string">`-name`</span> :按文件名查找</span><br><span class="line">            -   <span class="string">`-empty`</span> :空文件或文件夹</span><br><span class="line">            -   <span class="string">`-type 文件类型`</span> :查找指定类型的文件(f、d、l、b、c) f 代替 - 普通文件</span><br><span class="line">            -   <span class="string">`-not`</span>:取反</span><br><span class="line">            -   <span class="string">`-ls`</span>:显示匹配文件的</span><br><span class="line">            -   <span class="string">`-size`</span>:</span><br><span class="line">            -   <span class="string">`-i`</span>:忽略大小写</span><br><span class="line">            -   权限相关</span><br><span class="line">                -   <span class="string">`-user root`</span>:查找所有者是 root 的文件</span><br><span class="line">                -   <span class="string">`-group`</span></span><br><span class="line">                -   <span class="string">`-uid`</span></span><br><span class="line">                -   <span class="string">`-gid`</span></span><br><span class="line">                -   <span class="string">`-nouser`</span>:没有所有者的文件(用户被删除)</span><br><span class="line">                -   <span class="string">`-nogroup`</span>:没有所属组的文件</span><br><span class="line">                -   <span class="string">`-perm 755`</span>:按权限查找</span><br><span class="line">                    -   模糊查询</span><br><span class="line">                        -   <span class="string">`perm /620`</span> :查找出所有者拥有 r 或 w 权限，或者所属组有 w 权限的文件，<span class="string">`0代表不理会`</span></span><br><span class="line">                        -   <span class="string">`perm -220`</span>:并且</span><br><span class="line">                    -   特殊权限查找(<span class="variable constant_">SUID</span> <span class="number">4</span>、<span class="variable constant_">SGID</span> <span class="number">2</span>、<span class="title class_">Sbit</span> <span class="number">1</span>)</span><br><span class="line">                        -   <span class="string">`perm /7000`</span>:最高位是特殊权限，umask 查看</span><br><span class="line"></span><br><span class="line">        -   <span class="string">`查找条件`</span>:文件名称是什么、文件大小、文件类型、从属关系、权限等（通配符）</span><br><span class="line">        -   <span class="string">`处理动作`</span>:对找到的文件 进行指令操作</span><br><span class="line">            -   <span class="string">`find`</span> 找到的是文本信息内容可以直接 | 加指令操作</span><br><span class="line">            -   -exec ls xxx &#123;&#125; \; 找到结果当做文件处理，但是指令后面需要加 &#123;&#125; \;结尾,| &#123;&#125; 代表找到的文件 \结束</span><br><span class="line">            -   | xargs ls xxx 通过管道使用，功能与-exec 类似</span><br><span class="line">                -   | xargs -i cp &#123;&#125; /root 加-i 可以用&#123;&#125;的功能</span><br><span class="line">                -   echo <span class="string">&quot;a b c&quot;</span>|xargs mkdir 直接新建a、b、c目录</span><br><span class="line">                -   xargs单独使用</span><br><span class="line">                    -   xargs (默认跟echo命令),将用户输入作为标准输出,用在后面跟的命令上</span><br><span class="line">        -   根据时间戳查找</span><br><span class="line">            -   天 : <span class="string">`-atime`</span>(访问时间) 、<span class="string">`-mtime`</span>(更改内容时间)、<span class="string">`-ctime`</span>(改动时间)</span><br><span class="line">                -   find /etc -atime +<span class="number">7</span> (七天内没有被访问过的文件)</span><br><span class="line">                -   find /etc -atime -<span class="number">7</span> (七天内被访问过的文件)</span><br><span class="line">            -   分 : <span class="string">`-amin`</span>(访问时间) 、<span class="string">`-mmin`</span>(更改内容时间)、<span class="string">`-cmin`</span>(改动时间)</span><br><span class="line">                -   find /etc -amin -<span class="number">7</span> (七分钟内被访问过的文件)</span><br></pre></td></tr></table></figure>

<h3 id="文件内容操作"><a href="#文件内容操作" class="headerlink" title="文件内容操作"></a>文件内容操作</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">-   <span class="string">`cat`</span>：查看文本文件内容</span><br><span class="line">    -   <span class="string">`-n`</span>：显示行号</span><br><span class="line">-   <span class="string">`more`</span>：查看文本文件内容，分页功能满屏幕自动暂停，底部自动退出</span><br><span class="line">-   <span class="string">`less`</span>：查看文本文件内容，分页功能满屏幕自动暂停，手动按 Q 退出</span><br><span class="line">-   <span class="string">`head -3 和 tail -3`</span>：查看文件前 n 行或最后 n 行，指定行数</span><br><span class="line"></span><br><span class="line">    -   <span class="string">`-f`</span>：监听文件数据变化</span><br><span class="line"></span><br><span class="line">-   <span class="string">`wc -l`</span>：查看文件行数</span><br><span class="line">-   <span class="string">`echo &#x27;abc&#x27;`</span>：输出内容，查看变量内容</span><br><span class="line"></span><br><span class="line">    -   <span class="string">`&gt; a.txt`</span>: 内容重定向到指定文件</span><br><span class="line"></span><br><span class="line">-   <span class="string">`sed`</span>:[sed -i <span class="string">&quot;s#https#http#g&quot;</span> <span class="string">`grep http -rl VERO`</span>] 将 <span class="variable constant_">VERO</span> 下所有子目录所有文件里的 http 替换成 https</span><br><span class="line">    -   <span class="string">`-i`</span>:直接修改文件</span><br><span class="line">-   <span class="string">`grep &quot;key&quot; &lt;file-path&gt;`</span>:从指定文件中查找关键字（支持正则不支持通配符）</span><br><span class="line">    -   <span class="string">`&quot;^key$&quot;`</span>：正则直接操作关键字</span><br><span class="line">    -   <span class="string">`-n`</span>：行号</span><br><span class="line">    -   <span class="string">`-v`</span>：查找关键字规则不匹配的</span><br><span class="line">    -   <span class="string">`-i`</span>：不区分大小写</span><br><span class="line">    -   <span class="string">`-w`</span>：独立单词</span><br><span class="line">    -   <span class="string">`-r`</span>：递归查询子目录文件内容</span><br><span class="line">    -   <span class="string">`-o`</span>:只显示匹配到的</span><br><span class="line">    -   <span class="string">`-l`</span>:只输出匹配内容的文件名</span><br><span class="line">-   <span class="string">`diff &lt;file-name&gt; &lt;file-name2&gt;`</span>:比较两个文件，列出不同的内容</span><br><span class="line"></span><br><span class="line">    -   对比规则</span><br><span class="line">        -   <span class="string">`a`</span>:增加</span><br><span class="line">        -   <span class="string">`d`</span>:删除</span><br><span class="line">        -   <span class="string">`c`</span>:改变</span><br><span class="line">        -   <span class="string">`&lt;`</span>:前面文件 <span class="number">1</span></span><br><span class="line">        -   <span class="string">`&gt;`</span>:后面文件 <span class="number">2</span></span><br><span class="line">    -   <span class="string">`12a13;&gt;abcd`</span>:文件 <span class="number">2</span> 比文件 <span class="number">1</span> 新增加了一行内容，文件 <span class="number">2</span> 多出 abcd</span><br><span class="line"></span><br><span class="line">-   <span class="string">`stat`</span>:查看文件元数据（文件自生的属性权限时间）</span><br><span class="line">    -   <span class="string">`modify time`</span>:文件内容改变的时候（通过这个可以指定有人改了文件内容）</span><br><span class="line">    -   <span class="string">`change time`</span>:文件元数据改变的时候</span><br></pre></td></tr></table></figure>

<h3 id="常用模块"><a href="#常用模块" class="headerlink" title="常用模块"></a>常用模块</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">-   时间操作</span><br><span class="line">    -   <span class="string">`date`</span>: 系统时间</span><br><span class="line">        -   <span class="string">`+&quot;%F %T&quot;`</span>:<span class="number">2020</span>-<span class="number">09</span>-<span class="number">10</span> <span class="number">10</span>:<span class="number">00</span>:<span class="number">00</span></span><br><span class="line">    -   <span class="string">`hwclock`</span>:硬件 <span class="variable constant_">BIOS</span> 时间</span><br><span class="line">    -   <span class="string">`cat`</span>:日历</span><br><span class="line">    -   <span class="string">`sudo timedatectl set-local-rtc 1`</span>:同步系统时间</span><br></pre></td></tr></table></figure>

<h3 id="基本系统运用指令"><a href="#基本系统运用指令" class="headerlink" title="基本系统运用指令"></a>基本系统运用指令</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">-   <span class="string">`ifconfig`</span> ：查看 ip （ens33 格式、lo、virbr0 虚拟网卡）等网卡</span><br><span class="line">    -   <span class="string">`watch -n 1 ifconfig`</span> 实时查看网络状态，<span class="attr">RX</span>:接收，<span class="attr">TX</span>:发送 =&gt; (<span class="variable constant_">KB</span> = 数值/<span class="number">1000</span>)</span><br><span class="line">-   <span class="string">`reboot|init 6`</span> ：重启</span><br><span class="line">-   <span class="string">`poweroff|init 0`</span> ：关机</span><br><span class="line">-   <span class="string">`shutdown`</span></span><br><span class="line">    -   -h now ：立即关机</span><br><span class="line">    -   -h +<span class="number">15</span> ：一段时间后关机</span><br><span class="line">    -   -r now ：立即重启</span><br><span class="line">    -   -r +<span class="number">15</span> <span class="string">&quot;给其他在线用户发送信息&quot;</span> ：一段时间后重启</span><br><span class="line">    -   -c ：取消之前 shutdown 的操作</span><br></pre></td></tr></table></figure>

<h3 id="字符"><a href="#字符" class="headerlink" title="字符"></a>字符</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">-   通配符(一般文件路径操作是通配符,文件内容操作用正则)</span><br><span class="line">    -   <span class="string">`*`</span>：匹配任意数量任意字符 -&gt; 正则 <span class="string">`.*`</span></span><br><span class="line">    -   <span class="string">`?`</span>：匹配单个任意字符 -&gt; 正则 <span class="string">`.`</span></span><br><span class="line">    -   <span class="string">`[]`</span>： 匹配指定范围内任意单个字符 如：[<span class="number">0</span>-<span class="number">9</span>]其中之一，[!<span class="number">12</span>]不能是 <span class="number">1</span> <span class="number">2</span></span><br><span class="line">-   <span class="string">`&#123;&#125;`</span>：可展开如：mkdir /home/&#123;a,b,c&#125; 创建三个文件</span><br><span class="line">-   <span class="string">`|`</span>:管道（将管道左边的执行结果作为管道右边命令的输入）</span><br><span class="line">    -   将很多命令链接起来执行</span><br></pre></td></tr></table></figure>

<h2 id="系统管理"><a href="#系统管理" class="headerlink" title="系统管理"></a>系统管理</h2><h3 id="用户、组"><a href="#用户、组" class="headerlink" title="用户、组"></a>用户、组</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br></pre></td><td class="code"><pre><span class="line">-   用户(<span class="string">`/etc/passwd`</span>)</span><br><span class="line">    -   基础信息</span><br><span class="line">        -   <span class="string">`id UserName`</span>:查看用户 <span class="variable constant_">ID</span>，组 <span class="variable constant_">ID</span> 信息</span><br><span class="line">        -   <span class="string">`useradd UserName`</span>:添加用户</span><br><span class="line">            -   <span class="string">`-u 1110`</span>:指定 <span class="variable constant_">UID</span></span><br><span class="line">            -   <span class="string">`-d /HomeDir`</span>:指定家目录</span><br><span class="line">            -   <span class="string">`-g GroupName`</span>:指定基本组不用默认的</span><br><span class="line">            -   <span class="string">`-G GroupName`</span>:直接添加附加组，基本组不影响</span><br><span class="line">            -   <span class="string">`-e 2020-02-02`</span>:用户有效期到 <span class="number">2020</span>-<span class="number">02</span>-<span class="number">02</span></span><br><span class="line">            -   <span class="string">`-M`</span>:不创建家目录(一般配合<span class="string">`-s /sbin/nologin`</span>使用)</span><br><span class="line">            -   <span class="string">`-m`</span>:创建家目录</span><br><span class="line">            -   <span class="string">`-s`</span>:设置用户默认 shell</span><br><span class="line">        -   <span class="string">`usermod UserName`</span>:编辑用户属性（与 useradd 的参数基本一致）</span><br><span class="line">            -   <span class="string">`-m -d /HomeDir`</span>:指定新的家目录(-m 删除旧的)</span><br><span class="line">            -   <span class="string">`-l newUserName`</span>:更改用户名字</span><br><span class="line">            -   <span class="string">`-G GroupName`</span>:把该用户原来所以的附加组替换成这一个附加组</span><br><span class="line">            -   <span class="string">`-a -G GroupName`</span>:添加一个新的附加组</span><br><span class="line">        -   <span class="string">`su UserName`</span>:切换用户</span><br><span class="line">            -   <span class="string">`su - UserName`</span>:完全切换到新用户，环境工作路径等</span><br><span class="line">            -   <span class="string">`su -`</span>:切换到管理员 root</span><br><span class="line">                -   su 配置文件<span class="string">`/etc/pam.d/su`</span></span><br><span class="line">                -   取消注释 <span class="string">`auth required pam_wheel.so use_uid`</span>行</span><br><span class="line">                    -   只有<span class="string">`wheel`</span>组的用户才能切换 root</span><br><span class="line">        -   <span class="string">`sudo`</span>:临时获取管理员权限 ,配置文件<span class="string">`/etc/sudoers`</span></span><br><span class="line"></span><br><span class="line">            -   <span class="string">`lisi ALL=ALL`</span>:用户<span class="string">`lisi`</span>使用<span class="string">`sudo命令`</span>可以执行<span class="string">`root的所有`</span>操作</span><br><span class="line">            -   <span class="string">`lisi2 ALL=/usr/sbin/useradd,/usr/sbin/usermod`</span>:<span class="string">`lisi2`</span>使用<span class="string">`sudo`</span>只能执行这<span class="string">`指定的`</span>命令</span><br><span class="line">            -   <span class="string">`echo &quot;1&quot; | sudo -S /usr/local/nginx/sbin/nginx`</span>:sudo 直接输入密码，通过 -S</span><br><span class="line"></span><br><span class="line">        -   <span class="string">`userdel UserName`</span>:删除用户</span><br><span class="line">            -   <span class="string">`-r`</span>:同时删除家目录</span><br><span class="line"></span><br><span class="line">    -   用户类型</span><br><span class="line"></span><br><span class="line">        -   超级管理员用户:拥有最高权限的 <span class="title function_">root</span>(<span class="number">0</span>)</span><br><span class="line">        -   普通用户：创建的用户(<span class="number">1000</span> - <span class="number">60000</span>)</span><br><span class="line">        -   系统用户：不能登录的，系统自己创建用来运行某些程序的用户（程序都必须以某个用户的身份来运行）(<span class="number">1</span> - <span class="number">999</span>)</span><br><span class="line"></span><br><span class="line">    -   配置文件属性</span><br><span class="line">        -   属性:<span class="string">`lzoxun:x:1001:1001:lzoxun:/home/lzoxun:/bin/bash`</span></span><br><span class="line">        -   解析:<span class="string">`用户名:密码占位符:UID(用户ID):GID(基本组ID):描述 :家目录 :默认shell`</span></span><br><span class="line">    -   用户密码(<span class="string">`/etc/shadow`</span>)影子文件</span><br><span class="line">        -   <span class="string">`passwd UserName`</span>:设置密码</span><br><span class="line">            -   <span class="string">`-d`</span>:清除密码</span><br><span class="line">            -   <span class="string">`-l`</span>:锁定用户（在 shadow 密码前添加两个!!）</span><br><span class="line">            -   <span class="string">`-u`</span>:解除锁定</span><br><span class="line">            -   <span class="string">`--stdin`</span>:改变标准输入的地方(减少交互)</span><br><span class="line">                -   <span class="string">`echo &#x27;123&#x27;|passwd --stdin UserName`</span></span><br><span class="line">        -   加密</span><br><span class="line">            -   密码是通过 sha 加密的</span><br><span class="line">            -   <span class="string">`echo &#x27;123&#x27;|md5sum`</span>:md5 加密</span><br><span class="line">            -   <span class="string">`echo &#x27;123&#x27;|sha1sum`</span>:sha 加密 ...</span><br><span class="line"></span><br><span class="line">-   组(<span class="string">`/etc/group`</span>)</span><br><span class="line">    -   基础信息</span><br><span class="line">        -   创建用户时自动创建一个与用户同名的基本组</span><br><span class="line">        -   <span class="title class_">Linux</span> 用户必须有一个组,默认归属的<span class="string">`基本组(一个)`</span>,</span><br><span class="line">        -   <span class="title class_">Linux</span> 用户后期可以动态加入其他组，叫做<span class="string">`附加组(多个)`</span>,</span><br><span class="line">        -   <span class="string">`groupadd GroupName`</span>:创建组</span><br><span class="line">            -   <span class="string">`-g xxx`</span>:指定组 id</span><br><span class="line">        -   <span class="string">`groupdel GroupName`</span>:删除组（不能是用户的基本组）</span><br><span class="line">        -   <span class="string">`gpasswd -a UserName GroupName`</span>:给用户添加附加组,从而<span class="string">`得到新组所拥有的权限`</span></span><br><span class="line">        -   <span class="string">`gpasswd -d UserName GroupName`</span>:从组里删除用户</span><br><span class="line">    -   配置文件属性</span><br><span class="line">        -   属性:<span class="string">`root:x:1001:lzoxun`</span></span><br><span class="line">        -   解析:<span class="string">`组名:密码占位符:GID(组ID):哪些用户以root组作为附属组`</span></span><br></pre></td></tr></table></figure>

<h3 id="文件的权限与归属"><a href="#文件的权限与归属" class="headerlink" title="文件的权限与归属"></a>文件的权限与归属</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br></pre></td><td class="code"><pre><span class="line">-   权限（以下限制对 root 无效）</span><br><span class="line"></span><br><span class="line">    -   文件</span><br><span class="line">        -   <span class="title function_">read</span>(r):文件读取</span><br><span class="line">        -   <span class="title function_">write</span>(w):文件写入</span><br><span class="line">        -   <span class="title function_">execute</span>(x):文件执行(脚本文件并且有执行的权限就能运行了)</span><br><span class="line">    -   目录</span><br><span class="line">        -   <span class="title function_">read</span>(r):显示子目录,文件列表</span><br><span class="line">        -   <span class="title function_">write</span>(w):目录中新建、删除、子文件或目录(目录写权限可以删除目录内的所有文件)</span><br><span class="line">        -   <span class="title function_">execute</span>(x):使用 cd 命令进入,或退出目录</span><br><span class="line">    -   基础操作</span><br><span class="line">        -   <span class="string">`chmod 777 path`</span>:设置权限</span><br><span class="line">            -   数字操作</span><br><span class="line">                -   <span class="title function_">r</span>(<span class="number">4</span>)、<span class="title function_">w</span>(<span class="number">2</span>)、<span class="title function_">x</span>(<span class="number">1</span>)</span><br><span class="line">            -   字母操作</span><br><span class="line">                -   <span class="string">`chmod [ugoa][+-=][rwx] path`</span></span><br><span class="line">                -   <span class="title function_">u</span>(所有者)、<span class="title function_">g</span>(所属组)、<span class="title function_">o</span>(其他用户)、<span class="title function_">a</span>(全部)</span><br><span class="line">                -   +(添加)、-(减少)、=(直接设置新的权限)</span><br><span class="line">                -   <span class="string">`chmod o=r-x path`</span>:指定其他用户只有读和执行权限</span><br><span class="line">                -   <span class="string">`chmod a+w path`</span>:所有用户添加可写权限<span class="string">`a可省略`</span></span><br><span class="line">            -   chmod -<span class="title class_">Rf</span> <span class="number">777</span> <span class="attr">path</span>:强制递归授权</span><br><span class="line"></span><br><span class="line">-   归属</span><br><span class="line"></span><br><span class="line">    -   <span class="string">`chown`</span>:更改文件或目录的所有者、所属组</span><br><span class="line">        -   <span class="string">`chown root:admin FilePath`</span>:更改所有者与所属组</span><br><span class="line">        -   <span class="string">`chown root FilePath`</span>:更改所有者</span><br><span class="line">        -   <span class="string">`chown :admin FilePath`</span>:更改所属组</span><br><span class="line"></span><br><span class="line">-   高级权限</span><br><span class="line">    -   访问控制列表<span class="string">`facl`</span></span><br><span class="line">        -   前面的权限针对，所有者、所属组、其他人三类进行限制</span><br><span class="line">        -   优先级高于用户的基本权限</span><br><span class="line">        -   <span class="string">`facl`</span>可以针对某一个用户进行权限设置</span><br><span class="line">            -   <span class="string">`setfacl -m u:UserName:rwx FilePath`</span>:设置用户<span class="string">`UserName`</span>对<span class="string">`FilePath`</span>的 facl 控制权限为<span class="string">`rwx`</span></span><br><span class="line">            -   <span class="string">`setfacl -x u:UserName FilePath`</span>:取消用户<span class="string">`UserName`</span>对<span class="string">`FilePath`</span>的 facl 控制权限</span><br><span class="line">            -   <span class="string">`setfacl -b FilePath`</span>:取消所有人<span class="string">`FilePath`</span>的 facl 控制权限</span><br><span class="line">            -   <span class="string">`getfacl FilePath`</span>: 查看<span class="string">`FilePath`</span>facl 详细信息，以及相关用户</span><br><span class="line">                -   <span class="string">`mask 权限`</span>:某个文件所有用户 facl 权限最大值，文件设置 facl 后，原先组权限位置含义将替换成这个，组的权限在 facl 的 group 中有</span><br><span class="line">-   特殊权限</span><br><span class="line"></span><br><span class="line">    -   <span class="variable constant_">SET</span> 位权限（针对可执行文件或目录）</span><br><span class="line"></span><br><span class="line">        -   <span class="variable constant_">SUID</span>（对所有者设置 <span class="variable constant_">SET</span> 位权限）,权限值<span class="string">`0755`</span> <span class="number">0</span> 位置 +<span class="number">4</span></span><br><span class="line">            -   <span class="string">`-rws------`</span>:使执行该文件的<span class="string">`所有用户`</span>自动具有该文件<span class="string">`所有者`</span>的权限（所有者是 root,那么这些用户就有 root 权限）</span><br><span class="line">            -   如果给 cat 程序添加 <span class="variable constant_">SET</span> 权限，那么执行 cat 时所有用户都有管理员权限，都能参看任意文件了</span><br><span class="line">            -   <span class="string">` chmod u+s xxx`</span>:本来有执行权限加 <span class="variable constant_">SET</span> 位-&gt;显示小 s,否则显示大 S，<span class="string">`s只是占了位置不影响原来是否有x`</span></span><br><span class="line">        -   <span class="variable constant_">SGID</span>（对所属组内用户设置 <span class="variable constant_">SET</span> 位权限）,权限值<span class="string">`0755`</span> <span class="number">0</span> 位置 +<span class="number">2</span></span><br><span class="line">            -   给一个<span class="string">`目录设置了SGID`</span>,那么以后<span class="string">`这个目录`</span>下<span class="string">`创建`</span>了<span class="string">`文件`</span>或<span class="string">`目录`</span>，他们的<span class="string">`所属组`</span>都是<span class="string">`SGID目录的所属组`</span>，不是<span class="string">`所有者`</span>的基本组</span><br><span class="line">            -   作用是<span class="string">`目录设置了SGID`</span>所属组的用户，创建的文件可以互相更改，适合协同办公</span><br><span class="line">            -   <span class="string">` chmod g+s xxx`</span></span><br><span class="line"></span><br><span class="line">    -   粘滞位权限(<span class="title class_">Sticky</span> <span class="title class_">Bit</span>) <span class="variable constant_">SBIT</span> ,权限值<span class="string">`0755`</span> <span class="number">0</span> 位置 +<span class="number">1</span></span><br><span class="line">        -   把对一个东西权限范围限制在直接的身上</span><br><span class="line">        -   如对一个目录有写的权限，本来是可以删除目录下所有文件的，限制成只能删除你自己的文件</span><br><span class="line">        -   <span class="string">` chmod o+t xxx`</span></span><br><span class="line">        -   <span class="number">777</span> 权限的文件夹比较需要</span><br><span class="line"></span><br><span class="line">-   其他</span><br><span class="line">    -   umask（掩码）</span><br><span class="line">        -   直接只有命令输入当前用户的 umask 值</span><br><span class="line">        -   普通目录权限<span class="string">`最大值777`</span>，普通文件不能执行的<span class="string">`最大权限666`</span></span><br><span class="line">        -   如果当前用户<span class="string">`umask`</span>为<span class="string">`022`</span>,那么创建文件夹默认权限是<span class="string">`777去掉022=755`</span>，文件默认<span class="string">`666去掉022=644`</span></span><br><span class="line">        -   <span class="string">`umask xxx`</span>:临时修改 umask 值，就是修改默认文件的权限, (永久修改需要在启动文件执行该命令)</span><br></pre></td></tr></table></figure>

<h3 id="其他特殊权限-（暂时跳过-课程-1-66-75-）"><a href="#其他特殊权限-（暂时跳过-课程-1-66-75-）" class="headerlink" title="其他特殊权限 （暂时跳过 课程 1 66~75 ）"></a>其他特殊权限 （暂时跳过 课程 1 66~75 ）</h3><h2 id="文件"><a href="#文件" class="headerlink" title="文件"></a>文件</h2><blockquote>
<p>ls -l 查看文件详情</p>
</blockquote>
<h3 id="文件详情"><a href="#文件详情" class="headerlink" title="文件详情"></a>文件详情</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">-   <span class="string">`第一组 权限`</span>：[类型][rwx rwx rwx]</span><br><span class="line">    -   第一位代表类型</span><br><span class="line">        -   <span class="string">`-`</span>：普通文件</span><br><span class="line">        -   <span class="string">`d`</span>：文件夹</span><br><span class="line">        -   <span class="string">`l`</span>：软链接，快捷方式</span><br><span class="line">        -   <span class="string">`c`</span>：字符设备</span><br><span class="line">        -   <span class="string">`b`</span>：块设备</span><br><span class="line">    -   第一组[rwx]读写执行</span><br><span class="line">        -   <span class="string">`所有者`</span>对文件的操作权限</span><br><span class="line">    -   第二组[rwx]读写执行</span><br><span class="line">        -   <span class="string">`所属组`</span>对文件的操作权限（文件未设置 facl 权限的话，否则代表 mask 的值）</span><br><span class="line">        -   其他用户的附加组是该文件的所属组，那么那个用户的权限就是第二个[rwx]</span><br><span class="line">        -   或这个所属组的所有成员(<span class="string">`/etc/group`</span>中最后那个位置)，权限都是第二个[rwx]</span><br><span class="line">    -   第三组[rwx]读写执行</span><br><span class="line">        -   <span class="string">`其他用户`</span>对文件的操作权限</span><br><span class="line">        -   其他用户指的是所有者与所属组成员<span class="string">`之外`</span>的用户</span><br><span class="line">    -   <span class="string">`.`</span> (默认是. 当用 facl 对该文件进行设置时会变成 <span class="string">`+`</span>)、</span><br><span class="line">-   <span class="string">`第二组`</span>：被硬链接的次数</span><br><span class="line">-   <span class="string">`第三组`</span>：文件所有者(创建文件的用户)</span><br><span class="line">-   <span class="string">`第四组`</span>：文件所属组(创建文件用户的基本组)</span><br><span class="line">-   <span class="string">`第五组`</span>：文件大小</span><br><span class="line">-   <span class="string">`第六组`</span>：创建或最后一次修改时间</span><br><span class="line">-   <span class="string">`第七组`</span>：文件名（.当前目录、.. 上级目录）</span><br></pre></td></tr></table></figure>

<h3 id="目录信息"><a href="#目录信息" class="headerlink" title="目录信息"></a>目录信息</h3><blockquote>
<p>一切皆文件 、绝对路径、相对路径</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">-   <span class="string">`/`</span>：跟目录(所以文件的起点)</span><br><span class="line">-   <span class="string">`/boot`</span>：存系统启动相关文件，<span class="title class_">Kernel</span> 内核的位置，通常独立划分区</span><br><span class="line">-   <span class="string">`/etc`</span>：存各种配置文件，类似 <span class="variable language_">window</span> 注册表</span><br><span class="line">-   <span class="string">`/dev`</span>：存硬盘、光驱、鼠标等硬件设备</span><br><span class="line">-   <span class="string">`/bin`</span>：存最常用的基本命令，<span class="string">`任何用户`</span>都有权限访问</span><br><span class="line">-   <span class="string">`/sbin`</span>：存最基本管理命令，<span class="string">`管理员`</span>才有权限访问</span><br><span class="line">-   <span class="string">`/usr`</span>：默认软件安装路径</span><br><span class="line">-   <span class="string">`/home`</span>：普通用户家目录</span><br><span class="line">-   <span class="string">`/root`</span>：root 户家目录</span><br><span class="line">-   <span class="string">`/mnt`</span>：<span class="string">`临时`</span>挂载存储设备</span><br><span class="line">-   <span class="string">`/media`</span>：系统自动挂载可移动存储设备</span><br><span class="line">-   <span class="string">`/var`</span>：存放<span class="string">`经常变化`</span>的文件</span><br><span class="line">-   <span class="string">`/proc`</span>：存放进程文件,伪文件系统（存的是内存里的数据）</span><br><span class="line">-   <span class="string">`/run`</span>：存放临时文件，重启消失</span><br><span class="line">-   <span class="string">`/lib、/lib64`</span> ： 链接库</span><br><span class="line"></span><br><span class="line">-   <span class="string">`srv`</span></span><br><span class="line">-   <span class="string">`tmp`</span></span><br><span class="line">-   <span class="string">`sys`</span></span><br><span class="line">-   <span class="string">`/opt`</span>:第三方应用程序</span><br></pre></td></tr></table></figure>

<h2 id="vi-与-vim"><a href="#vi-与-vim" class="headerlink" title="vi 与 vim"></a>vi 与 vim</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br></pre></td><td class="code"><pre><span class="line">-   vi 老版本编辑器，功能不齐全</span><br><span class="line">-   vim</span><br><span class="line">    -   工作模式</span><br><span class="line">        -   <span class="string">`命令模式`</span>（移动光标、字符串查找、删除、复制、粘贴等操作）</span><br><span class="line">            -   默认命令模式</span><br><span class="line">        -   <span class="string">`插入模式`</span>（修改文件内容）</span><br><span class="line">            -   命令模式下 <span class="title function_">a</span>(after)、i、<span class="title function_">o</span>(添加行插入) 进入</span><br><span class="line">            -   <span class="string">`Esc`</span> 退出到命令模式</span><br><span class="line">        -   <span class="string">`行末模式`</span>（保存、退出、文件内容查找与替换）</span><br><span class="line">            -   命令模式下按 “:” 进入</span><br><span class="line">            -   <span class="string">`Esc`</span> 退出到命令模式</span><br><span class="line">        -   <span class="string">`可视模式`</span>（可进行选择）</span><br><span class="line">            -   <span class="string">`v`</span>:按字符选</span><br><span class="line">            -   <span class="string">`V`</span>:按行选</span><br><span class="line">    -   命令模式常用操作</span><br><span class="line">        -   移动光标</span><br><span class="line">            -   <span class="string">`G`</span>:移到最后</span><br><span class="line">            -   <span class="string">`gg`</span>:移到第一行</span><br><span class="line">            -   <span class="string">`行号 G | 行号 gg`</span>:跳到指定行</span><br><span class="line">            -   <span class="string">`Home | ^ | 0 `</span>:回到行首</span><br><span class="line">            -   <span class="string">`End | $`</span>:回到行尾</span><br><span class="line">            -   <span class="string">`n 上下左右`</span>:向指定方向移动 n 位</span><br><span class="line">        -   上下翻页</span><br><span class="line">            -   <span class="string">`Ctrl+B | Page Up`</span></span><br><span class="line">            -   <span class="string">`Ctrl+F | Page Down`</span></span><br><span class="line">        -   复制、粘贴、删除</span><br><span class="line">            -   <span class="string">`x|Del`</span>:删除单个字符</span><br><span class="line">            -   <span class="string">`d`</span>:删除</span><br><span class="line">                -   <span class="string">`dd`</span>:&lt;字符功能&gt;一整行</span><br><span class="line">                -   <span class="string">`#dd`</span>:&lt;字符功能&gt;从光标从光标出开始的#行字符</span><br><span class="line">                -   <span class="string">`d^`</span>:&lt;字符功能&gt;从光标之前到行首的字符</span><br><span class="line">                -   <span class="string">`d$`</span>:&lt;字符功能&gt;从光标之处到行尾的字符</span><br><span class="line">            -   <span class="string">`y`</span>:复制</span><br><span class="line">            -   <span class="string">`p`</span>:粘贴</span><br><span class="line">        -   查找</span><br><span class="line">            -   <span class="string">`/查找的内容`</span>：回车查找，按 <span class="string">`n下N上`</span> 查找其他</span><br><span class="line">            -   <span class="string">`?查找的内容`</span>：从下往上查找</span><br><span class="line">        -   撤销</span><br><span class="line">            -   <span class="string">`u`</span>:撤销</span><br><span class="line">    -   末行模式常用操作</span><br><span class="line">        -   <span class="string">`:wq | :x `</span>:保存并退出</span><br><span class="line">        -   <span class="string">`:q`</span>:未修改退出</span><br><span class="line">        -   <span class="string">`:q!`</span>:放弃修改并强制退出</span><br><span class="line">        -   <span class="string">`:w path`</span>:另存为</span><br><span class="line">        -   替换</span><br><span class="line">            -   <span class="string">`:[范围] s/替换的内容/新内容[/g][/c]`</span>:[]可有可无</span><br><span class="line">            -   <span class="string">`:% s/word/newword/gc`</span></span><br><span class="line">            -   <span class="string">`:1,10 s/word/newword/gc`</span></span><br><span class="line">    -   常用设置</span><br><span class="line">        -   <span class="string">`:set nu |:set nu`</span> 设置行号</span><br></pre></td></tr></table></figure>

<h2 id="磁盘管理与文件管理系统"><a href="#磁盘管理与文件管理系统" class="headerlink" title="磁盘管理与文件管理系统"></a>磁盘管理与文件管理系统</h2><h3 id="磁盘分区与格式化"><a href="#磁盘分区与格式化" class="headerlink" title="磁盘分区与格式化"></a>磁盘分区与格式化</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br></pre></td><td class="code"><pre><span class="line">-   存储设备</span><br><span class="line">    -   硬盘接口 <span class="title function_">IDE</span>(I)、<span class="title function_">SCSI</span>(S)(服务器常用)、<span class="title function_">SATA</span>(A)、<span class="title class_">NVMe</span>(V)等</span><br><span class="line">    -   分区：早期硬盘只能有四个主分区，后面越来越多，四个不够，就可以拿一个变成扩展分区,扩展分区里可以创建很多的逻辑分区（如果需要的分区不超过四个就没必要使用逻辑分区）</span><br><span class="line">    -   <span class="title class_">Linux</span> 中每个磁盘，以及磁盘中的每个分区都是用<span class="string">`文件表示`</span>的</span><br><span class="line">    -   <span class="variable constant_">USB</span> 接口移动设备读书 sd 开头，光驱光盘默认都是/dev/cdrom</span><br><span class="line">    -   硬盘:第一块硬盘 sda、第二块 sdb、第三块 sdc....</span><br><span class="line">        -   普通分区 sda1、sda2、sda3、sda4 或 sdb1、sdb2..</span><br><span class="line">        -   逻辑分区 从 <span class="number">5</span> 开始，sda5</span><br><span class="line">        -   <span class="string">`fdisk`</span>:分区指令</span><br><span class="line">            -   <span class="string">`fdisk -l /dev/sda`</span>:查看 sda 硬盘详细信息</span><br><span class="line">            -   <span class="string">`fdisk /dev/sdb`</span>:分区硬盘 <span class="number">2</span></span><br><span class="line">                -   主分区</span><br><span class="line">                    -   p 主分区，e 扩展分区</span><br><span class="line">                    -   选择分区号</span><br><span class="line">                    -   起始扇区（可以默认）</span><br><span class="line">                    -   结束扇区（可以 +10G）</span><br><span class="line">                    -   输入 p 查看，n 继续创建新分区</span><br><span class="line">                -   扩展分区</span><br><span class="line">                    -   p 主分区，e 扩展分区</span><br><span class="line">                    -   选择分区号</span><br><span class="line">                    -   起始扇区（可以默认）</span><br><span class="line">                    -   结束扇区(不填直接到结尾)</span><br><span class="line">                -   如果有了扩展分区，那么继续按 n 时，就没有 e 了，只能选择 p 和 <span class="title function_">l</span>(逻辑分区)</span><br><span class="line">                -   <span class="string">`w`</span>：保存退出，<span class="string">`q`</span>:不保存，<span class="string">`Ctrl+退格可以撤销`</span></span><br><span class="line">                -   <span class="string">`cat /proc/partitions`</span> :查看是否生效</span><br><span class="line">                -   执行指令按 d 删除分区</span><br><span class="line">            -   swap 交换分区，虚拟内存(内存不够是从硬盘临时拿出一点单做内存用)</span><br><span class="line">        -   格式化</span><br><span class="line">            -   低级格式化：划分磁道与扇区（物理操作，对硬盘硬件影响大）</span><br><span class="line">            -   高级格式化</span><br><span class="line">                -   文件系统 <span class="string">`/etc/filesystems`</span></span><br><span class="line">                    -   win：主要有 <span class="string">`NTFS`</span> 、<span class="string">`FAT32`</span>(单文件大小不能超过 4G)等</span><br><span class="line">                    -   <span class="title class_">Linux</span>:</span><br><span class="line">                        -   ext 系列</span><br><span class="line">                        -   xfs 系列</span><br><span class="line">                -   格式化操作，创建文件系统</span><br><span class="line">                    -   <span class="string">`mkfs -t xfs /dev/sdb5`</span>:以 xfs 文件系统格式化第二块硬盘第五分区</span><br><span class="line">        -   挂载</span><br><span class="line">            -   挂载就是<span class="string">`指定一个目录`</span>作为挂载点(分区入口)，用户通过操作这个目录数据对硬盘分区进行<span class="string">`数据存取操作`</span></span><br><span class="line">            -   根目录默认，被单做挂载点的目录会被从这边分离出去</span><br><span class="line">            -   不论指定那个目录作为挂载点，成功后都会与从原来的地方分离开，成为空目录，卸载后复原</span><br><span class="line">            -   <span class="string">`mount [-t 文件系统类型] 设备文件名 挂载点目录`</span></span><br><span class="line">                -   <span class="string">`mount -a`</span>:安装 <span class="string">`/etc/fstab`</span> 配置项目自动挂载</span><br><span class="line">            -   <span class="attr">autofs</span>:如果挂载很多，有不经常用,光盘、U盘、<span class="variable constant_">NFS</span>等 可以通过 autofs服务 动态挂载</span><br><span class="line">                -   autofs 守护进程他会在后台自动检测用户要访问却还未挂载的文件系统,自动检测该文件系统是否存在，如果存在则自动挂载，一段时间没有使用会自动卸载</span><br><span class="line">                -   缺点：不适合高并发场景</span><br><span class="line">                -   <span class="string">`/etc/auto.master`</span> 里 <span class="string">`/misc /etc/auto.misc`</span> 下 添加自动挂载配置文件 <span class="string">`/- /etc/auto.home`</span></span><br><span class="line">                -   <span class="string">`/etc/auto.home`</span> =&gt; 本地文件夹位置/share -rw,soft,intr 远程<span class="attr">IP</span>:<span class="regexp">/xxxx/</span>xx (或移动硬盘类型 /dev/sdb1)</span><br><span class="line">                -   检测本地关注情况，systemctl start autofs 启动服务，访问/share 此时已经自动挂载好了</span><br><span class="line">            -   <span class="string">`df`</span>:查看所以以及挂载设备</span><br><span class="line">                -   <span class="string">`-h`</span></span><br><span class="line">                -   <span class="string">`-T`</span>: 查看文件系统格式</span><br><span class="line">            -   <span class="string">`umount 挂载点`</span>:卸载</span><br><span class="line">                -   前提 设备不能处于 busy 状态</span><br><span class="line">            -   <span class="title class_">Linux</span> 至少<span class="string">`/`</span>、<span class="string">`/boot(启动引导)`</span>，swap 交换分区三个分区</span><br><span class="line">        -   新硬盘经过分区、格式化、挂载之后就可以正常使用了</span><br><span class="line">    -   光盘</span><br><span class="line">        -   <span class="string">`mount /dev/cdroom /xxxx`</span></span><br><span class="line">    -   U 盘插入之后会多个 sdxx,虚拟机的话要先断开与主机的链接</span><br><span class="line">        -   右键 -&gt; 可移动设备 -&gt; 找到 <span class="variable constant_">USB</span> - &gt;断开与主机的链接</span><br><span class="line">    -   iso 镜像文件</span><br><span class="line"></span><br><span class="line">        -   <span class="string">`mount -o loop isoPosition /xxx`</span></span><br><span class="line"></span><br><span class="line">    -   配置文件自动挂载<span class="string">`/etc/fstab`</span></span><br><span class="line">        -   得到设备 <span class="attr">UUID</span>:<span class="string">`blkid /dev/sdb1`</span></span><br><span class="line">        -   属性</span><br><span class="line">            -   <span class="variable constant_">UUID</span>=7051740a-<span class="number">3450</span>-4f9f-<span class="number">9879</span>-aa3ba007d06b, /boot, xfs, defaults , <span class="number">0</span>, <span class="number">0</span></span><br><span class="line">            -   <span class="variable constant_">UUID</span> 或分区名 挂载点 文件系统类型 挂载选项(入 iso 的-o ，一般 <span class="keyword">default</span>) 是否备份(<span class="number">0</span> 不要) 是否开机检测硬盘(<span class="number">0</span> 不要，<span class="number">1</span> 先检查，<span class="number">2</span> 后检测)</span><br><span class="line"></span><br><span class="line">-   手动安装发行版分区</span><br><span class="line">    -   300M 左右- 挂载 boot 和 esp - fat32 ：引导分区</span><br><span class="line">    -   10G+ - 挂载 opt - ext4 ：第三方程序</span><br><span class="line">    -   20G+ - 挂载 / - ext4</span><br><span class="line">    -   8G - 无挂载 - <span class="attr">linuxswap</span>:虚拟内存交互分区</span><br><span class="line">    -   其他 - 挂载 /home - ext4</span><br></pre></td></tr></table></figure>

<h3 id="quota-磁盘配额"><a href="#quota-磁盘配额" class="headerlink" title="quota 磁盘配额"></a>quota 磁盘配额</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line">-   对磁盘容量或文件数量进行限制</span><br><span class="line">-   磁盘配额需要手动启用,只在指定的分区中有效</span><br><span class="line">-   主要针对系统中指定的<span class="string">`用户`</span>，<span class="string">`组`</span>进行限制，没指定的不受影响</span><br><span class="line">    -   如果是组，那么组内<span class="string">`基本组`</span>成员使用的<span class="string">`容量`</span>或<span class="string">`文件数量`</span>,<span class="string">`之和`</span>不能超过限制</span><br><span class="line">    -   <span class="string">` user`</span> 的附加组为<span class="string">` wheel`</span>,给 <span class="string">`wheel`</span> 设置权限配额,<span class="string">`与 suser 无关`</span></span><br><span class="line">-   限制方法</span><br><span class="line">    -   软限制：可以短时间超过,但指定时间得处理掉</span><br><span class="line">    -   硬限制：绝对不能超过限制</span><br><span class="line">-   设置配置文件 <span class="string">`/etc/fstab`</span></span><br><span class="line"></span><br><span class="line">    -   <span class="string">`quota -u UserName`</span>:<span class="string">`查看用户`</span>在哪个分区存在配额限制</span><br><span class="line">    -   <span class="string">`quota -g GroupName`</span>:查看<span class="string">`指定组`</span>在哪个分区存在配额限制</span><br><span class="line">    -   <span class="string">`repquota 分区挂载点目录`</span>:<span class="string">`查看该分区`</span>限制的用户详细</span><br><span class="line"></span><br><span class="line">    -   通过挂载选项启用配额:<span class="string">`defaults,acl,uquota,gquota`</span></span><br><span class="line">        -   <span class="string">`acl`</span>: 使新分区支持 facl 权限列表</span><br><span class="line">        -   <span class="string">`gquota`</span>: 对组设置权限配额</span><br><span class="line">        -   <span class="string">`uquota`</span>: 对用户设置权限配额</span><br><span class="line">    -   <span class="string">`edquota -u UserName`</span>: 如果挂载选择存在 uquota</span><br><span class="line"></span><br><span class="line">        -   编辑选项:</span><br><span class="line"></span><br><span class="line">            -   <span class="string">`Filesystem`</span>:分区</span><br><span class="line"></span><br><span class="line">            -   <span class="string">`blocks`</span>:对磁盘空间进行限制(值是已用空间)</span><br><span class="line">            -   <span class="string">`soft`</span>:软限制(单位 k)</span><br><span class="line">            -   <span class="string">`hard`</span>:硬限制(手动输入限制大小,单位 k)</span><br><span class="line"></span><br><span class="line">            -   <span class="string">`inodes`</span>:文件个数进行限制(值是已消耗个数)</span><br><span class="line">            -   <span class="string">`soft`</span>:软限制(个)</span><br><span class="line">            -   <span class="string">`hard`</span>:硬限制(手动输入限制个数,单位个)</span><br><span class="line"></span><br><span class="line">    -   <span class="string">`edquota -g GroupName`</span>: 如果挂载选择存在 gquota</span><br></pre></td></tr></table></figure>

<h3 id="RAID-磁盘阵列（暂时跳过-课程-1-92-104-）"><a href="#RAID-磁盘阵列（暂时跳过-课程-1-92-104-）" class="headerlink" title="RAID 磁盘阵列（暂时跳过 课程 1 92~104 ）"></a>RAID 磁盘阵列（暂时跳过 课程 1 92~104 ）</h3><blockquote>
<p>RAID 将多块<code>独立的硬盘</code>按照<code>不同方式</code>组合起来形成一个<code>硬盘组</code>，从而提供比单个硬盘<code>更高的储存性能</code>和<code>提供数据备份</code>的技术</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">-   组合方式一 | <span class="string">`READ0`</span></span><br><span class="line">    -   优点:将<span class="string">`数据`</span>保持到<span class="string">`多块`</span>硬盘，多块硬盘<span class="string">`同时`</span>进行工作，从而<span class="string">`提升效率`</span></span><br><span class="line">    -   缺点:一块硬盘坏了，数据就没用了</span><br><span class="line">-   组合方式二 | <span class="string">`READ1`</span></span><br><span class="line">    -   优点:将写入一个硬盘的数据原样复制到其他硬盘，不提升效率，但是提升物理安全性</span><br><span class="line">    -   缺点:不提升效率</span><br><span class="line">-   组合方式三 | <span class="string">`READ1 + 0`</span></span><br><span class="line">    -   至少需要四块硬盘，合并前面两种</span><br><span class="line">-   组合方式四 | <span class="string">`READ5`</span></span><br></pre></td></tr></table></figure>

<h2 id="软件安装"><a href="#软件安装" class="headerlink" title="软件安装"></a>软件安装</h2><h3 id="预备知识"><a href="#预备知识" class="headerlink" title="预备知识"></a>预备知识</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">-   知识点</span><br><span class="line">    -   <span class="attr">block</span>:<span class="title class_">Linux</span> 基本存储单位，大小是 <span class="number">8</span> 个扇区(512B)组合而成,大小 4k</span><br><span class="line">-   <span class="string">`du`</span>:查看文件占用磁盘空间（ll 查看的是文件的大小）</span><br><span class="line">    -   <span class="string">`-h`</span>:人性化显示</span><br><span class="line">    -   <span class="string">`-s`</span>:汇总，查看目录占用磁盘空间</span><br><span class="line">-   <span class="string">`tar`</span>:文件的打包 tar 可以调用 gzip、bzip2、xz 等方式进行压缩或解压</span><br><span class="line"></span><br><span class="line">    -   参数: tar [选项] 打包或压缩后的文件名 需要打包的源文件或目录</span><br><span class="line">    -   <span class="string">`tar -zcvf newName.tar /etc`</span>:参数 f 必须放最后 f 与新文件名有关</span><br><span class="line"></span><br><span class="line">        -   <span class="string">`-c`</span>:穿件 tar 格式包文件，并不会对包文件进行压缩</span><br><span class="line">        -   <span class="string">`-v`</span>:查看列出打包详情</span><br><span class="line">        -   <span class="string">`-f`</span>:新文件名</span><br><span class="line"></span><br><span class="line">        -   <span class="string">`-z`</span>:选定压缩方式为<span class="string">`gzip`</span>,<span class="string">`.tar.gz`</span>，结果:大、快</span><br><span class="line">        -   <span class="string">`-j`</span>:选定压缩方式为<span class="string">`bzip2`</span>,<span class="string">`.tar.bz2`</span>，结果:中、中</span><br><span class="line">        -   <span class="string">`-J`</span>:选定压缩方式为<span class="string">`xz`</span>,<span class="string">`.tar.xz`</span>,结果:小、慢</span><br><span class="line"></span><br><span class="line">    -   <span class="string">`tar -xf newName.tar -C 解到目录`</span>:解包</span><br><span class="line">        -   <span class="string">`-x`</span>:解包</span><br><span class="line">    -   <span class="string">`tar -zxf newName.tar.gz -C 解到目录`</span>:解压缩解包（解压-z|j|J 可以省略）</span><br><span class="line">        -   <span class="string">`-z`</span>:解 gzip 压缩</span><br><span class="line">        -   <span class="string">`-j`</span>:解 bzip2 压缩</span><br><span class="line">        -   <span class="string">`-J`</span>:解 xz 压缩</span><br><span class="line">    -   <span class="string">`tar -tf newName.tar.gz`</span>:不解压的情况查看包的内容</span><br><span class="line">-   zip操作</span><br><span class="line">    -   <span class="string">`zip`</span>：压缩</span><br><span class="line">        -   <span class="string">`zip -q -r html.zip /home/html`</span>:将 /home/html/ 这个目录下所有文件和文件夹打包为当前目录下的 html.<span class="property">zip</span></span><br><span class="line">        -   <span class="string">`zip -q -r html.zip *`</span>: <span class="regexp">/home/</span>html 目录下直接执行压缩</span><br><span class="line">        -   <span class="string">`zip -dv html.zip index.html`</span>:从压缩包html.<span class="property">zip</span>中删除index.<span class="property">html</span>这个文件</span><br><span class="line">        -   参数</span><br><span class="line">            -   <span class="string">`-r`</span>：递归处理</span><br><span class="line">            -   <span class="string">`-q`</span>:不显示执行过程</span><br><span class="line">            -   <span class="string">`-d`</span>:从压缩文件内删除指定文件</span><br><span class="line">            -   <span class="string">`-v`</span>:显示指令执行过程或显示版本信息</span><br><span class="line">    -   <span class="string">`unzip`</span>：解压</span><br><span class="line">        -   <span class="string">`unzip apc.zip`</span>:解压文件到当前目录</span><br><span class="line">        -   <span class="string">`unzip -n apc.zip -d /home/xxx`</span>:-d 解压文件到当指定目录，-n 不覆盖原有文件,-o 覆盖</span><br><span class="line">        -   <span class="string">`unzip -v abc.zip`</span>:查看zip信息，不解压</span><br><span class="line">        -   <span class="string">`unzip -l abc.zip`</span>:查看zip简洁信息，不解压</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="源码安装"><a href="#源码安装" class="headerlink" title="源码安装"></a>源码安装</h3><blockquote>
<p>用户获得源代码之后,需要自行编译代码并解决许多软件依赖关系，比较困难，<code>适合所有发行版</code></p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">-   必须存在编译软件 如:gcc</span><br><span class="line">    -   <span class="string">`wget`</span>:将程序源码下载到本地</span><br><span class="line">-   步骤</span><br><span class="line">    -   解包：<span class="string">`tar`</span></span><br><span class="line">        -   得到源码并解压,得到源码文件，并进入</span><br><span class="line">    -   配置：<span class="string">`./configure`</span></span><br><span class="line">        -   <span class="string">`./configure --prefix=/usr/local/xxxxx`</span>:配置程序安装目录</span><br><span class="line">        -   配置结果保存在源码目录的<span class="string">`makefile`</span>文件里</span><br><span class="line">    -   编译:<span class="string">`make`</span></span><br><span class="line">        -   将源码转二进制数</span><br><span class="line">    -   安装与部署：<span class="string">`make install`</span></span><br><span class="line">-   使用</span><br><span class="line">    -   进入<span class="string">`/usr/local/xxxxx/bin</span></span><br><span class="line"><span class="string">    -   执行 ./xxxxx.probe 主程序</span></span><br></pre></td></tr></table></figure>

<h3 id="rpm-RedHat-Packet-Manager"><a href="#rpm-RedHat-Packet-Manager" class="headerlink" title="rpm(RedHat Packet Manager)"></a>rpm(RedHat Packet Manager)</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">-   红帽公司将源码<span class="string">`编译好了`</span>,可以直接使用的<span class="string">`.rpm`</span>软件包</span><br><span class="line">-   只能在红帽派系发行版本中使用</span><br><span class="line">-   rpm 软件包直接存在着复杂的依赖关系</span><br><span class="line">-   结构</span><br><span class="line">    -   <span class="string">`软件名称`</span>-<span class="string">`版本号`</span>-<span class="string">`发布号`</span>.<span class="string">`硬件平台`</span>.<span class="property">rpm</span></span><br><span class="line">    -   <span class="string">`yum info xxx`</span>可以查看 rpm 包详细信息</span><br><span class="line">-   <span class="string">`rpm -q 服务`</span>:查询服务是否安装</span><br><span class="line">    -   <span class="string">`rpm -qa | grep ssh`</span>:查询已安装与 ssh 有关的软件包信息</span><br><span class="line">    -   <span class="string">`-qi`</span>:已安装软件包的详细信息</span><br><span class="line">    -   <span class="string">`-ql`</span>:查看服务各个文件的安装目录（安装之后系统的相关文件）</span><br><span class="line">        <span class="string">`-qc`</span>:查看<span class="string">`服务配置文件`</span>位置</span><br><span class="line">        <span class="string">`-qf file`</span>:查看<span class="string">`文件属于哪个服务安装`</span>的</span><br></pre></td></tr></table></figure>

<h3 id="yum-安装"><a href="#yum-安装" class="headerlink" title="yum 安装"></a>yum 安装</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><span class="line">-   自动解决 rpm 的依赖问题(自动安装需要的依赖，不需要手动安装)</span><br><span class="line">-   配置 yum 源或 yum 仓库(yum repo)</span><br><span class="line">    -   仓库中存放大量 rpm 软件包，以及软件包相关的元数据文件（repodata 目录下）</span><br><span class="line">    -   <span class="string">`yum源`</span>配置定义文件以 <span class="string">`.repo`</span>为后缀，存放在<span class="string">`/etc/yum.repos.d/`</span>目录下</span><br><span class="line">    -   <span class="string">`yum源`</span>获取获取方式</span><br><span class="line">        -   <span class="number">1</span>、来自网上服务器</span><br><span class="line">        -   <span class="number">2</span>、本地系统光盘安装(.<span class="property">ios</span> 系统镜像 )</span><br><span class="line">    -   安装阿里云 yum 源：</span><br><span class="line">        -   备份或删除 /etc/yum.<span class="property">repos</span>.<span class="property">d</span>/下的 yum 源文件</span><br><span class="line">        -   wget -O /etc/yum.<span class="property">repos</span>.<span class="property">d</span>/<span class="title class_">CentOS</span>-<span class="title class_">Base</span>.<span class="property">repo</span> <span class="attr">http</span>:<span class="comment">//mirrors.aliyun.com/repo/Centos-7.repo</span></span><br><span class="line">        -   wget <span class="attr">http</span>:<span class="comment">//mirrors.aliyun.com/repo/epel-7.repo --directory-prefix=/etc/yum.repos.d</span></span><br><span class="line">        -   yum clean all &amp;&amp; yum makecache</span><br><span class="line">        -   <span class="string">`yum makecache`</span> 更新 yum 源</span><br><span class="line">        -   <span class="string">`yum repolist`</span> 查看 yum 源</span><br><span class="line">-   yum 源文件详解</span><br><span class="line">    -   <span class="string">`[xxxxx]`</span>:yum 源的名称，自定义且唯一</span><br><span class="line">    -   <span class="string">`name=xxxx xx`</span>:自定义 yum 源的描述这个 yum 源的信息</span><br><span class="line">    -   <span class="string">`baseurl`</span>:指定 yum 源的访问路径</span><br><span class="line">        -   <span class="string">`baseurl=http://xxx`</span>:指向外部网站</span><br><span class="line">        -   <span class="string">`baseurl=ftp://xxx`</span>:指向 <span class="variable constant_">FTP</span> 服务器</span><br><span class="line">        -   <span class="string">`baseurl=file://xxx`</span>:指向本地的某个目录</span><br><span class="line">    -   <span class="string">`enabled`</span>:<span class="number">1</span> 启用，<span class="number">0</span> 禁用，没有的话默认为 <span class="number">1</span></span><br><span class="line">    -   <span class="string">`gpgcheck`</span>:检测 rpm 包来源的合法性</span><br><span class="line">        -   <span class="number">0</span> 不检查</span><br><span class="line">        -   <span class="number">1</span> 检查，并且要加 gpgkey=<span class="attr">file</span>:<span class="comment">///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 指定公钥位置</span></span><br><span class="line">        -   数字签名</span><br><span class="line">        -   centos7 的公钥位置：<span class="string">`/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7`</span></span><br><span class="line">-   yum 指令</span><br><span class="line">    -   <span class="string">`yum list`</span>:查看系统已安装的软件包(@开头)与可安装的软件包(无@)</span><br><span class="line">    -   <span class="string">`yum repolist`</span>:yum 源列表</span><br><span class="line">    -   <span class="string">`yum info 服务`</span>:查看 info 信息</span><br><span class="line">    -   <span class="string">`yum install 服务`</span>:安装服务</span><br><span class="line">        -   <span class="string">`yum install 服务 -y`</span>:不用询问</span><br><span class="line">    -   <span class="string">`yum remove 服务`</span>:删除软件包</span><br><span class="line">    -   <span class="string">`yum clean all`</span>:清除</span><br><span class="line">        -   重新构建缓存：yum makecache 然后再执行yum update</span><br><span class="line">    -   <span class="string">`yum search ifconfig`</span>:查看 ifconfig 属于哪个软件包</span><br><span class="line">-   常用服务</span><br><span class="line">    -   <span class="string">`lrzsz`</span>:远程文件上传下载</span><br><span class="line">        -   <span class="string">`rz`</span>:从客户端上传文件到 linux</span><br><span class="line">        -   <span class="string">`sz filename`</span>:从 linux 下载文件到客户端</span><br><span class="line">    -   安装rpm</span><br><span class="line">        -   wget <span class="attr">https</span>:<span class="comment">//dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm</span></span><br><span class="line">        -   sudo yum install ./google-chrome-stable_current_*.<span class="property">rpm</span></span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">案例</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">下载新的repo文件</span></span><br><span class="line">wget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo</span><br><span class="line">wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">替换源地址</span></span><br><span class="line">sed -i &#x27;s/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g&#x27;  /etc/yum.repos.d/Centos-vault-8.5.2111.repo</span><br><span class="line">sed -i &#x27;s/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g&#x27;  /etc/yum.repos.d/epel-archive-8.repo</span><br><span class="line"></span><br><span class="line">yum clean all</span><br><span class="line">yum makecache</span><br></pre></td></tr></table></figure>

<h3 id="DNF-新的-yum"><a href="#DNF-新的-yum" class="headerlink" title="DNF (新的 yum)"></a>DNF (新的 yum)</h3><blockquote>
<p>新一代的 RPM 软件包管理器</p>
</blockquote>
<p><a target="_blank" rel="noopener" href="https://wangchujiang.com/linux-command/c/dnf.html">文档</a><br><a target="_blank" rel="noopener" href="http://mirrors.aliyun.com/repo/">http://mirrors.aliyun.com/repo/</a> 阿里云源下载列表</p>
<p>centos8 添加 epel 源</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">测试状态</span></span><br><span class="line">dnf repolist epel</span><br><span class="line">dnf repolist epel -v</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">建立元数据缓存</span></span><br><span class="line">dnf makecache</span><br></pre></td></tr></table></figure>

<p>指令</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">dnf search mysql-server <span class="comment">// 查询包</span></span><br><span class="line">dnf info mysql-server <span class="comment">// 查看它提供包的版本信息</span></span><br></pre></td></tr></table></figure>

<h2 id="进程与服务管理"><a href="#进程与服务管理" class="headerlink" title="进程与服务管理"></a>进程与服务管理</h2><h3 id="进程（PID）"><a href="#进程（PID）" class="headerlink" title="进程（PID）"></a>进程（PID）</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br></pre></td><td class="code"><pre><span class="line">-   概念</span><br><span class="line">    -   程序与进程的差别</span><br><span class="line">        -   程序:静态的，放在磁盘上的可执行文件</span><br><span class="line">        -   进程:动态的,运行中的程序实例</span><br><span class="line">        -   程序是一些指令的<span class="string">`有序集合`</span>，进程是<span class="string">`程序执行的过程`</span>，进程的<span class="string">`状态是变化`</span>的包括创建、调度、和消亡</span><br><span class="line">        -   程序只要运行，就成了是<span class="string">`进程`</span>,<span class="string">`每运行一次`</span>就会创建一个进程</span><br><span class="line">    -   进程就是系统<span class="string">`内存`</span>中<span class="string">`正在运行`</span>的程序，某些程序可以同时产生<span class="string">`多个`</span>进程</span><br><span class="line">    -   <span class="variable constant_">CPU</span> 通过内存去处理这些程序，所以核对线程多处理进程速度越快</span><br><span class="line">    -   没有运行的程序只占用硬盘空间，不消耗系统资源</span><br><span class="line">    -   每个进程都一个父进程来触发它，除非起始进程</span><br><span class="line">    -   linux scentos7 起始进程 <span class="string">`systemd`</span>，开机后第一个进程，其他进程都是通过起始进程运行的子进程</span><br><span class="line">    -   子进程是父进程创建的，父进程结束，需要自觉把子进程杀死，如果特殊情况没有结束的子进程，就是<span class="string">`僵尸状态`</span></span><br><span class="line">-   基础状态</span><br><span class="line">    -   运行态</span><br><span class="line">        -   某个进程分配到 cpu 正在处理器上执行的状态，单 <span class="variable constant_">CPU</span> 单线程的处理器，一个时间最多有一个</span><br><span class="line">        -   正在占用 cpu 运行，四核八线程可以同时存在八个运行态进程</span><br><span class="line">    -   就绪态</span><br><span class="line">        -   准备好，等前面进程 cpu 时间片时间到，进程调度轮到自己时，直接可以开始工作</span><br><span class="line">    -   阻塞态</span><br><span class="line">        -   等待一个时机到来触发的程序，触发后转就绪态， 如:I/O 交互</span><br><span class="line">    -   进程调度通过<span class="string">`时间片轮转、上下文切换`</span></span><br><span class="line">-   进程控制块(task_struct 结构 中的 <span class="variable constant_">PCB</span>)??</span><br><span class="line">-   <span class="title class_">Linux</span> 详细状态</span><br><span class="line">    -   <span class="string">`R`</span>:可运行状态</span><br><span class="line">    -   <span class="string">`S`</span>:可中断的等待状态</span><br><span class="line">    -   <span class="string">`D`</span>:不可中断的等待状态</span><br><span class="line">    -   <span class="string">`Z`</span>:僵尸状态</span><br><span class="line">    -   <span class="string">`T`</span>:暂停状态</span><br><span class="line">    -   下级分类</span><br><span class="line">        -   <span class="string">`S+`</span>:前台进程</span><br><span class="line">        -   <span class="string">`l`</span>:多线程进程</span><br><span class="line">        -   <span class="string">`N`</span>:低优先级进程</span><br><span class="line">        -   <span class="string">`&lt;`</span>:高优先级进程</span><br><span class="line">        -   <span class="string">`s`</span>:改进程是会话领导者</span><br><span class="line">-   属性</span><br><span class="line">    -   <span class="string">`PID`</span>:名称</span><br><span class="line">    -   <span class="string">`PPID`</span>:父级 <span class="variable constant_">ID</span></span><br><span class="line">    -   <span class="string">`UID`</span>:启动进程的用户(系统自建的一些用户就是拿来启动特定进程的)</span><br><span class="line">    -   <span class="string">`STAT`</span>:进程状态</span><br><span class="line">    -   <span class="string">`SZ|%MEM`</span>:用掉的內存的大小、百分比</span><br><span class="line">    -</span><br><span class="line">-   管理</span><br><span class="line">    -   <span class="string">`pidof 进程`</span>:查看指定进程 <span class="title function_">PID</span>(处理起始进程 <span class="variable constant_">PID</span> 固定为 <span class="number">1</span>，其他的都是随机变化的)</span><br><span class="line">    -   <span class="string">`ps`</span>:当前用户当前终端启动的线程</span><br><span class="line">        -   <span class="string">`a`</span>:显示与当前终端有关的所有进程</span><br><span class="line">        -   <span class="string">`x`</span>:显示与当前终端无关的所有进程</span><br><span class="line">        -   <span class="string">`u`</span>:显示影响用户的信息(用户名、cpu、内存等)</span><br><span class="line">        -   <span class="string">`-aux`</span>: 风格一</span><br><span class="line">        -   <span class="string">`-ef`</span>:风格二 显示所有运行的进程，bin显示启动进程的命令（可以看到 <span class="variable constant_">PPID</span>）</span><br><span class="line">        -   <span class="string">`ajx`</span>:...</span><br><span class="line">    -   <span class="string">`top`</span>:查看动态进程信息(htop 插件的作用)</span><br><span class="line">        -   第一行:<span class="string">`当前时间`</span> up <span class="string">`运行多久`</span>,<span class="string">`几个用户上线`</span>, load <span class="attr">average</span>:<span class="string">`过去1、5、15分钟内CPU平均负载`</span></span><br><span class="line">        -   第二行:<span class="title class_">Tasks</span> 任务:<span class="string">`任务总数`</span>,<span class="string">`运行态个数`</span>,<span class="string">`就绪态个数`</span>,<span class="string">`阻塞态个数`</span>,<span class="string">`僵死态个数`</span></span><br><span class="line">        -   第三行:%<span class="attr">CPU</span>:<span class="string">`用户开进程占比`</span>,<span class="string">`系统进程占比`</span>,,<span class="string">`闲置CPU`</span></span><br><span class="line">        -   第四行:<span class="title class_">Mem</span> 内存:总内存，可用量，已用量，缓冲或缓存</span><br><span class="line">        -   第五行:虚拟内存信息</span><br><span class="line">    -   <span class="string">`who`</span>:查看当前那些用户在登录</span><br><span class="line">    -   <span class="string">`systemctl start httpd`</span>:启动 httpd 这个服务</span><br><span class="line">-   控制进程</span><br><span class="line">    -   手工启动</span><br><span class="line">        -   前台启动</span><br><span class="line">        -   后台启动</span><br><span class="line">            -   某些操作一直监听不会断，在指令后面添加 <span class="string">`&amp; `</span>转入后台运行,打印编号[n]</span><br><span class="line">            -   或<span class="string">`ctrl+z`</span>临时转入后台</span><br><span class="line">            -   <span class="string">`jobs -l`</span> 查看后台进程列表</span><br><span class="line">            -   <span class="string">`fg n`</span>:转前台进程</span><br><span class="line">            -   <span class="string">`kill 进程ID`</span>:中断进程</span><br><span class="line">    -   调度启动</span><br><span class="line">    -   关闭终端所有程序自动关闭</span><br><span class="line">        -   <span class="string">`nohup nc xxx &amp;`</span>:解除 nc 服务与终端的关系，使终端关闭程序继续运行</span><br><span class="line">        -   与服务器如果关闭终端，程序也会关闭的话，可以用exit退出，而不是直接关闭</span><br><span class="line">        -   <span class="string">`tmux`</span> 不属于当前终端，里面开启的进程也不会随着终端关闭二停止</span><br><span class="line">    -   终止进程</span><br><span class="line">        -   <span class="string">`ctrl+c`</span></span><br><span class="line">        -   <span class="string">`kill PID`</span>:结束指定进程</span><br><span class="line">            -   <span class="string">`-9`</span>:强制终止</span><br><span class="line">        -   <span class="string">`killall 程序名`</span>:删除与指定程序的所有子进程</span><br><span class="line">-   监视系统信息</span><br><span class="line">    -   监视用户信息</span><br><span class="line">        -   <span class="string">`users`</span>:查看几个用户在登录</span><br><span class="line">        -   <span class="string">`who`</span>:查看几个用户在登录详情</span><br><span class="line">        -   <span class="string">`w`</span>:查看几个用户在登录，查看更详细信息</span><br><span class="line">        -   <span class="string">`last`</span>:登录信息，查看某个用户从哪里登录过系统<span class="string">`通过日志`</span></span><br><span class="line">        -   找到用户后 通过杀死终端进程把用户踢走</span><br><span class="line">    -   资源占用信息</span><br><span class="line">        -   <span class="string">`cat /proc/cpuinfo `</span>:查看 cpu 信息</span><br><span class="line">        -   <span class="string">`free`</span>:查看内存情况</span><br><span class="line">            -   <span class="string">`-h`</span>:人性化显示</span><br><span class="line">            -   <span class="string">`-s 3`</span>:动态显示 <span class="number">3</span> 秒更新</span><br><span class="line">            -   <span class="attr">available</span>:可用容量，大于空闲分区 free，不够用可以从缓存中取一部分</span><br><span class="line">            -   如果用户从来没使用过交换分区(used <span class="number">0</span>),说明物理内存充足</span><br></pre></td></tr></table></figure>

<h3 id="服务"><a href="#服务" class="headerlink" title="服务"></a>服务</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">-   概念</span><br><span class="line">    -   服务实在系统后台运行、并等待用户或其他软件调用的一类特殊程序</span><br><span class="line">    -   父进程是初始化进程 <span class="variable constant_">PPID</span> 为 <span class="number">1</span>，与终端无关 ,<span class="number">0</span> 一般为调度进程(交换进程)</span><br><span class="line">    -   服务程序结尾一般带<span class="string">`d`</span></span><br><span class="line">    -   比较重要的是一项对外提供功能的网络服务,运行后，通常系统中都会开发相应的端口</span><br><span class="line">-   指令</span><br><span class="line"></span><br><span class="line">    -   <span class="string">`pstree`</span>:查看进程数</span><br><span class="line">    -   <span class="string">`systemd`</span>:cenos7 的初始化进程（之前的是<span class="string">`init`</span>）</span><br><span class="line"></span><br><span class="line">        -   核心概念 <span class="title function_">unit</span>(单元)</span><br><span class="line"></span><br><span class="line">            -   <span class="title class_">Server</span> unit</span><br><span class="line">                -   systemd 通过 unit 管理功能，每个<span class="string">`unit`</span>都有一个配置文件，存在/usr/lib/systemd/system 或 /etc/systemd/system 中</span><br><span class="line">                -   配置文件都以<span class="string">`.service`</span>结尾</span><br><span class="line">            -   <span class="title class_">Target</span> unit</span><br><span class="line"></span><br><span class="line">                -   .<span class="property">target</span> 结尾</span><br><span class="line">                -   设置运行级别</span><br><span class="line"></span><br><span class="line">            -   。。。。</span><br><span class="line"></span><br><span class="line">    -   <span class="string">`systemctl`</span>:服务管理(sshd 开启了才能远程链接，防火墙设置允许)</span><br><span class="line">        -   <span class="string">`start|stop|status|restart|reload &lt;server-name&gt;`</span>:启动|停止|查看状态|重启|重新加载 服务</span><br><span class="line">        -   restart 与 reload 的差别，重启是停止再启动，重新加载是不停止重新读取配置文件</span><br><span class="line">        -   <span class="string">`systemctl enable sshd.service`</span>:设置开机自启</span><br><span class="line">        -   <span class="string">`systemctl is-enabled sshd`</span>:查看是否开机自启</span><br><span class="line">        -   <span class="string">`list-unit-files --type service`</span>:查看开机自启的服务列表</span><br><span class="line">        -   <span class="string">`list-units`</span>:查看所以单元</span><br><span class="line">            -   <span class="string">`--type=service`</span>:只看 service 类型正在运行的服务</span><br><span class="line">            -   <span class="string">`--type=service --all`</span>:只看 service 类型所有的服务</span><br><span class="line"></span><br><span class="line">-   完整的服务管理流程</span><br><span class="line">    -   安装相关服务程序</span><br><span class="line">    -   运行服务</span><br><span class="line">    -   将服务设置开机自启</span><br><span class="line">    -   对服务进行配置</span><br><span class="line">    -   重启或者从新加载服务</span><br><span class="line">-   常用服务以及作用</span><br><span class="line">    -   <span class="string">`vsftpd`</span>:作用:使远程通过 ftp 上传下载</span><br></pre></td></tr></table></figure>

<h3 id="运行级别（目标）"><a href="#运行级别（目标）" class="headerlink" title="运行级别（目标）"></a>运行级别（目标）</h3><blockquote>
<p>指定级别可启动的特定服务类型（os7 以前用 init 表示，现在 runlevel[0~6]）表示 ctrl+alt+f3</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">-   目标(<span class="string">`/usr/lib/systemd/system`</span>)</span><br><span class="line">    -   <span class="string">`runlevel0.target`</span>: poweroff.<span class="title function_">target</span>(<span class="string">`不运行服务 关机`</span>)</span><br><span class="line">    -   <span class="string">`runlevel1.target`</span>: resuce.<span class="title function_">target</span>(<span class="string">`救援|单例|安全模式`</span>)</span><br><span class="line">    -   <span class="string">`runlevel2.target`</span>: multi-user.<span class="property">target</span></span><br><span class="line">    -   <span class="string">`runlevel3.target`</span>: multi-user.<span class="property">target</span></span><br><span class="line">    -   <span class="string">`runlevel4.target`</span>: multi-user.<span class="title function_">target</span>(<span class="string">`2，3，4多用户模式`</span>，不运行图形界面级相关服务，字符界面)</span><br><span class="line">    -   <span class="string">`runlevel5.target`</span>: graphical.<span class="title function_">target</span>(<span class="string">`图形相关服务`</span>)</span><br><span class="line">    -   <span class="string">`runlevel6.target`</span>: reboot.<span class="title function_">target</span>(<span class="string">`重启`</span>)</span><br><span class="line">-   操作</span><br><span class="line">    -   os7 用<span class="string">`systemctl`</span> 代替以前的<span class="string">`runlevel和init`</span></span><br><span class="line">    -   <span class="string">`systemctl get-default`</span>:查看默认运行级别</span><br><span class="line">    -   <span class="string">`systemctl set-default multi-user.target`</span>:设置默认运行级别</span><br><span class="line">    -   <span class="string">`systemctl set-default graphical.target`</span>:默认图像界面启动</span><br><span class="line">    -   <span class="string">`runlevel`</span>:查看当前运行级别（N <span class="number">5</span>,从 <span class="title class_">Null</span> 到 <span class="number">5</span>）</span><br><span class="line">    -   <span class="string">`init 运行级别数字`</span>:临时切换运行级别</span><br><span class="line">    -   os7 中 本质是将：<span class="string">`/etc/systemd/system/default.target`</span> 软连接指向 运行级别所在的文件</span><br><span class="line">-   通过救援模式重置 root 密码</span><br><span class="line">    -   只能在本地登录才能使用，不能通过远程操作</span><br><span class="line">    -   启动是按 e 进入引导界面</span><br><span class="line">    -   找到系统版本 root=xxx 那一段</span><br><span class="line">    -   找到 <span class="variable constant_">LANG</span>=zh_CN.<span class="property">UTF</span>-<span class="number">8</span></span><br><span class="line">    -   后面+ 空格 + rd.<span class="property">break</span> 进入救援模式</span><br><span class="line">    -   按 ctrl+x 重新进入系统</span><br></pre></td></tr></table></figure>

<p><img src= "" data-lazy-src="/../../static/img/resetrootpwd.png" alt="操作"></p>
<h3 id="计划任务-从未设置成功"><a href="#计划任务-从未设置成功" class="headerlink" title="计划任务(从未设置成功)"></a>计划任务(从未设置成功)</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line">-   一次性计划任务<span class="string">`at`</span></span><br><span class="line">    -   设置：</span><br><span class="line">        -   <span class="string">`at 时间14:00`</span></span><br><span class="line">        -   回车进入 at 交互模式,设置指定时间要做的事情</span><br><span class="line">        -   <span class="string">`ctrl+d`</span> 保存退出</span><br><span class="line">        -   模式内<span class="string">`ctrl+退格`</span>删除</span><br><span class="line"></span><br><span class="line">        -   echo <span class="string">&quot;ls&quot;</span> | at 时间</span><br><span class="line"></span><br><span class="line">    -   通过邮件接收</span><br><span class="line">        -   <span class="string">`mailx`</span>:查看邮件</span><br><span class="line">        -   输入邮件编号，打开指定邮件</span><br><span class="line">        -   <span class="string">`exit`</span>退出</span><br><span class="line">    -   参数</span><br><span class="line">        -   时间格式</span><br><span class="line">            -   <span class="string">`10:00 2021-04-13`</span></span><br><span class="line">            -   <span class="string">`10:00 tomorrow`</span></span><br><span class="line">            -   <span class="string">`now+3(minutes|hours|days)`</span>:三分钟后</span><br><span class="line">            -   <span class="string">`10:00`</span></span><br><span class="line">        -   查看任务列表</span><br><span class="line">            -   <span class="string">`at -l`</span>:任务列表</span><br><span class="line">            -   <span class="string">`at -c 编号`</span>:指定查看任务</span><br><span class="line">            -   <span class="string">`at -d 编号`</span>:删除任务</span><br><span class="line"></span><br><span class="line">-   周期性任务<span class="string">`cron|cronie(不要加d)`</span></span><br><span class="line">    -   <span class="string">`crontab -e`</span> 进入设置</span><br><span class="line">    -   <span class="string">`crontab -l`</span> 查看列表</span><br><span class="line">    -   时间周期格式</span><br><span class="line">        -   分钟 <span class="number">0</span>-<span class="number">59</span></span><br><span class="line">        -   小时 <span class="number">0</span>-<span class="number">23</span></span><br><span class="line">        -   日期 <span class="number">1</span>-<span class="number">31</span></span><br><span class="line">        -   月份 <span class="number">1</span>-<span class="number">12</span></span><br><span class="line">        -   星期 <span class="number">0</span>-<span class="number">6</span>，linux 的 <span class="number">0</span> 和 <span class="number">7</span> 都代表星期天(程序中cron表达式有的<span class="number">1</span>-<span class="number">7</span>，<span class="number">1</span>-星期天)</span><br><span class="line">        -   特殊符号:</span><br><span class="line">            -   <span class="string">`*`</span> 该范围任何时间</span><br><span class="line">            -   <span class="string">`,`</span> 多个选择 <span class="number">1</span>，<span class="number">2</span>，<span class="number">3</span></span><br><span class="line">            -   <span class="string">`-`</span> 多个选择 <span class="number">1</span>-<span class="number">3</span></span><br><span class="line">            -   <span class="string">`/`</span> 小时段: <span class="string">`8-18/2`</span> <span class="number">8</span> 点到 <span class="number">18</span> 点之间每隔 <span class="number">2</span> 小时执行一次</span><br><span class="line">                -   <span class="string">`0/4`</span>:从<span class="number">0</span>开始，每隔<span class="number">4</span>分/秒/小时。。执行一次</span><br><span class="line">                -   <span class="string">`*/4`</span>:从程序启动开始，每隔<span class="number">4</span>分/秒/小时。。执行一次</span><br><span class="line">    -   任务内容(<span class="string">`cron`</span>，<span class="string">`cronie`</span>不用路径)</span><br><span class="line">        -   指令必须带路径<span class="string">`where`</span> 可找到指令路径</span><br><span class="line">        -   任务与终端无关，无法获取到环境变量</span><br><span class="line">    -   案例</span><br><span class="line">        -   <span class="string">`30 20 12 4 * /usr/bin/cat /etc/passwd`</span></span><br><span class="line">        -   <span class="string">`30 * * * * * /usr/bin/cat /etc/passwd`</span></span><br><span class="line"></span><br><span class="line">    -   高级(<span class="title class_">Linux</span> cron 可能不支持)</span><br><span class="line">        -   cron的字符:<span class="string">&#x27;* , - / # ? L W C&#x27;</span></span><br><span class="line">        -   <span class="number">2</span>#<span class="number">3</span>:周<span class="number">0</span>-<span class="number">6</span>:某月第三个星期二,<span class="number">1</span>-<span class="number">7</span>表示第三个星期一</span><br><span class="line">        -   2<span class="attr">W</span>:天段，表示某月第二个工作日,<span class="variable constant_">LW</span>,某月最后一个工作日</span><br><span class="line">        -   <span class="attr">L</span>:天段,某月最后一天·,周段，5L某月最后一个星期五</span><br><span class="line">        -   <span class="attr">C</span>: 天段, 5C,某月<span class="number">5</span>号后的第一天 或 某月从第一天开始的后五天</span><br><span class="line">        -   <span class="attr">C</span>: 周段,1C,某月星期一后第一天</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="配置文件"><a href="#配置文件" class="headerlink" title="配置文件"></a>配置文件</h2><h3 id="bashrc"><a href="#bashrc" class="headerlink" title=".bashrc"></a>.bashrc</h3><blockquote>
<p>bash 在每次启动时都会加载 <code>.bashrc</code> 文件内容</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">-   别名</span><br><span class="line">    -   <span class="string">`alias ll = &quot;ls -lha&quot;`</span>:执行<span class="string">`ll`</span>就相当于执行<span class="string">`ls -lha`</span></span><br><span class="line">-   颜色设置</span><br><span class="line">    -   用户名颜色</span><br><span class="line">        -   <span class="string">`echo &quot;PS1=&#x27;\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[35;40m\]\W\[\e[0m\]]\$&#x27;&quot; &gt;&gt; ~/.bashrc`</span></span><br><span class="line">        -   <span class="attr">https</span>:<span class="comment">//blog.csdn.net/woshizhangliang999/article/details/103553567</span></span><br></pre></td></tr></table></figure>

<p>函数</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">执行 md <span class="built_in">dir</span> 创建<span class="built_in">dir</span>并进入</span></span><br><span class="line">md () &#123;</span><br><span class="line">    mkdir -p $1</span><br><span class="line">    cd $1</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="其他"><a href="#其他" class="headerlink" title="其他"></a>其他</h2><h3 id="提升效率"><a href="#提升效率" class="headerlink" title="提升效率"></a>提升效率</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">-   <span class="string">`tab`</span> 补全目录</span><br><span class="line">-   <span class="string">`history`</span>：查看历史命令</span><br><span class="line">-   <span class="string">`esc + .`</span>：快速得到上一次指令中的路径</span><br><span class="line">-   <span class="string">`--help`</span>：查看指令详细信息</span><br></pre></td></tr></table></figure>

<h3 id="不重要"><a href="#不重要" class="headerlink" title="不重要"></a>不重要</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">-   <span class="string">`$SHELL`</span> :一般全大写的系统自带环境变量</span><br><span class="line">-   <span class="string">`echo $PATH`</span> :查看环境变量</span><br><span class="line">-   <span class="string">`echo $?`</span> :查看上一条命令执行结果的对错(<span class="number">0</span>:正确，非 <span class="number">0</span>:错误)</span><br><span class="line">-   <span class="string">`source ~/.bashrc`</span>：更新配置文件立即生效</span><br><span class="line">-   <span class="string">`wall`</span> ：登陆的终端发送消息</span><br><span class="line">-   <span class="string">`alias`</span>：查看定义了的别名</span><br><span class="line">-   <span class="string">`unalias name`</span>:删除别名</span><br><span class="line">-   bash模式默认快捷键</span><br><span class="line">    -   ctrl+a 到行首</span><br><span class="line">    -   ctrl+e 到行尾</span><br><span class="line">    -   ctrl+u 删除光标之前的内容</span><br><span class="line">    -   ctrl+k 删除光标之后的内容</span><br><span class="line">    -   ctrl+l 清屏</span><br><span class="line">    -   tab 补全$PATH的存在内容</span><br><span class="line">-   查找相关统计</span><br><span class="line">    -   whoami</span><br><span class="line">    -   who</span><br><span class="line">    -   which</span><br><span class="line">    -   whereis</span><br></pre></td></tr></table></figure>

<h3 id="查看系统信息"><a href="#查看系统信息" class="headerlink" title="查看系统信息"></a>查看系统信息</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">-   <span class="string">`uname -a`</span> :查看系统信息</span><br><span class="line">-   <span class="string">`cat /proc/version`</span> :查看当前操作系统版本信息</span><br><span class="line">-   <span class="string">`cat /etc/issue`</span>:查看当前操作系统发行版信息</span><br><span class="line">-   <span class="string">`cat /proc/cpuinfo`</span>:<span class="variable constant_">CPU</span>信息</span><br><span class="line">-   <span class="string">`getconf LONG_BIT`</span>:多少位</span><br><span class="line">-   <span class="string">`cat /etc/sysconfig/network-scripts/xxx网卡`</span>:查看网络配置</span><br><span class="line">-   <span class="string">`lsblk 、fdisk -l、df -h`</span>:磁盘信息</span><br><span class="line">-   <span class="string">`free -mh`</span>:查看内存信息</span><br><span class="line">-   <span class="string">`netstat -lntp`</span>：查看监听的端口</span><br><span class="line">-   <span class="string">`cut -d: -f1 /etc/passwd`</span>:查看所有用户</span><br></pre></td></tr></table></figure>

<h3 id="不常用"><a href="#不常用" class="headerlink" title="不常用"></a>不常用</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">-   <span class="string">`chsh -s /bin/zsh`</span>:切换 shell</span><br><span class="line">-   <span class="string">`whereis cmmand`</span>:查询指令的可执行文件,源码文件,帮助文件的位置</span><br><span class="line">-   <span class="string">`ntpdate -u ntp.api.bz`</span>:矫正时间</span><br><span class="line">-   <span class="string">`/etc/os-release`</span>:操作系统表示</span><br></pre></td></tr></table></figure>

<h3 id="网络相关"><a href="#网络相关" class="headerlink" title="网络相关"></a>网络相关</h3><p>学习网络协议是计算机网络的核心概念<br>协议是计算机网络进行数据交互而建立的一种规则、约定、或标准的集合<br>网络协议与语言一样多种多样，后面出现了 TCP&#x2F;IP 网络协议标准已经是 internet 中的标准语言了（类似普通话）</p>
<blockquote>
<p>为了让不同计算机厂家的计算机能够进行沟通，在大范围进行网络同学，（ISO 国际标准化组织）划分成了七层 - ISO 七层模型</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br></pre></td><td class="code"><pre><span class="line">- <span class="number">1</span>、物理层</span><br><span class="line">- <span class="number">2</span>、数据链路层</span><br><span class="line">    -   <span class="number">1</span>,<span class="number">2</span> -&gt; 物理链路层</span><br><span class="line">    -   功能：以二进制的数据形式在物理媒介上进行传输数据</span><br><span class="line">    -   协议：<span class="variable constant_">ISO</span>@<span class="number">2100</span></span><br><span class="line">- <span class="number">3</span>、网络层</span><br><span class="line">    -   <span class="number">3</span>   -&gt; 网络</span><br><span class="line">    -   功能：为数据包选择路由(最快的路线)</span><br><span class="line">    -   协议：<span class="variable constant_">IP</span>、<span class="variable constant_">ICMP</span>、<span class="variable constant_">BGP</span>、<span class="variable constant_">OSPF</span>等</span><br><span class="line">- <span class="number">4</span>、传输层</span><br><span class="line">    -   <span class="number">4</span>   -&gt; 传输</span><br><span class="line">    -   功能：提供端对端的接口 <span class="variable constant_">IP</span> <span class="title class_">Port</span></span><br><span class="line">    -   协议：<span class="variable constant_">TCP</span>、<span class="variable constant_">UDP</span></span><br><span class="line">- <span class="number">5</span>、会话层</span><br><span class="line">- <span class="number">6</span>、表示层</span><br><span class="line">- <span class="number">7</span>、应用层</span><br><span class="line">    -   <span class="number">5</span>,<span class="number">6</span>,<span class="number">7</span> -&gt; 最接近用户的使用的三层</span><br><span class="line">    -   功能：提供文件传输、邮件、文件共享、数据加密等</span><br><span class="line">    -   协议：<span class="variable constant_">HTTP</span>、<span class="variable constant_">SNMP</span>、<span class="variable constant_">FTP</span>、<span class="variable constant_">NFS</span>、<span class="variable constant_">DNS</span>等</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">&gt; 应用层</span><br><span class="line">通过进层间的数据交互来完成特定的网络应用</span><br><span class="line">对于不同的网络应用需要用不同的网络协议</span><br><span class="line">    域名解析系统 <span class="variable constant_">DNS</span>协议</span><br><span class="line">    <span class="variable constant_">WEB</span>服务应用 <span class="variable constant_">HTTP</span>协议</span><br><span class="line">    邮件传输 <span class="variable constant_">SMTP</span>协议</span><br><span class="line">我们把应用层交互的数据称为**报文**</span><br><span class="line"></span><br><span class="line">-   <span class="variable constant_">DNS</span>协议</span><br><span class="line">域名解析系统，是一个互联网的分布式数据库，主要储存<span class="variable constant_">IP</span>和域名的对应关系，使用户可以通过域名访问互联网</span><br><span class="line"></span><br><span class="line">-   <span class="variable constant_">HTTP</span>协议</span><br><span class="line">超文本传输协议，是互联网上应用最广泛的网络协议，最初目的是为了发布和接收<span class="variable constant_">HTML</span>文件的</span><br><span class="line"></span><br><span class="line">&gt; 传输层</span><br><span class="line">向两台主机直接的进程进行提供数据传输,主要有两种(<span class="variable constant_">UDP</span>/<span class="variable constant_">TCP</span>)</span><br><span class="line"></span><br><span class="line">-   <span class="variable constant_">TCP</span> 传输控制协议</span><br><span class="line">    -   提供面向连接**可靠的**而数据传输协议</span><br><span class="line">    -   会与对方确认，没问题在给</span><br><span class="line">    -   可靠报文数据不重复不丢失</span><br><span class="line">-   <span class="variable constant_">UDP</span> 用户数据协议</span><br><span class="line">    -   提供无连接的，尽到他最大努力进行数据传输，不保证数据的而安全</span><br><span class="line">    -   不会确认，直接把数据仍给他</span><br><span class="line">    -   没有报文的</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="修改网络信息"><a href="#修改网络信息" class="headerlink" title="修改网络信息"></a>修改网络信息</h3><blockquote>
<p>ifconfig 临时修改, 配置文件中才能永久修改</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">进入/etc/sysconfig/network-script,打开网卡文件</span></span><br><span class="line">BOOTPROTO=&quot;dhcp/static&quot; # 动态/静态吗，static可以设置固定内网IP</span><br><span class="line">ONBOOT=&quot;yes&quot; # 开机读取</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="网络命令"><a href="#网络命令" class="headerlink" title="网络命令"></a>网络命令</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line">-   <span class="attr">ifconfig</span>:可能要自己安装</span><br><span class="line">    -   <span class="string">`ifconfig`</span></span><br><span class="line">        -   yum install net-tools 就有了</span><br><span class="line">        -   <span class="regexp">/etc/</span>sysconfig/network-script 网卡文件位置</span><br><span class="line">        -   <span class="title function_">inet</span>(<span class="title class_">IPV4</span>地址)、<span class="title function_">netmask</span>(子网掩码、<span class="title function_">broadcast</span>(广播地址)</span><br><span class="line">        -   <span class="variable constant_">RX</span>/<span class="variable constant_">TX</span> packages 网卡收/发流量数据包大小</span><br><span class="line">        -   ether <span class="attr">xx</span>:<span class="attr">xx</span>:<span class="attr">xx</span>:xx <span class="variable constant_">MAC</span>地址</span><br><span class="line">    -   ifconfig 网卡名 down/up：停止/启用网卡(危险操作)</span><br><span class="line">    -   ifconfig 可以临时更改网络信息ip mac地址等</span><br><span class="line"></span><br><span class="line">-   <span class="string">`route`</span>:源主机数据到目标主机的转发过程路线，路由类似互联网中转站，网络中的数据包就是通过一个个路由转发到目的地的</span><br><span class="line">    -   静态路由：<span class="title class_">Linux</span>机器配置的都是静态路由，运维人员通过route命令管理</span><br><span class="line">    -   动态路由：无需人为干预有路由器交换机自动分配规则</span><br><span class="line">    -   router -n：直接查看路由表</span><br><span class="line">        -   <span class="title class_">Destination</span>：网络号</span><br><span class="line">        -   <span class="title class_">Gateway</span>：网关地址，网络是通过改<span class="variable constant_">IP</span>出口，<span class="number">0.0</span><span class="number">.0</span><span class="number">.0</span>表示改路由信息是冲本机发出去的</span><br><span class="line">        -   <span class="title class_">Genmask</span>：子网掩码地址，<span class="variable constant_">IP</span>配合网整的子网掩码才是完整的网络信息</span><br><span class="line">        -   <span class="title class_">Flags</span>：标记网络状态，</span><br><span class="line">            -   U 运行的状态</span><br><span class="line">            -   G 表示这个是网关路由器</span><br><span class="line">            -   H 这个网关是一个主机</span><br><span class="line">            -   ！当前路由已经禁止</span><br><span class="line">-   <span class="string">`ip`</span>:</span><br><span class="line">    -   ip addr show：查看网络设备信息</span><br><span class="line">-   <span class="string">`ssh`</span>:openssh软件包的套件命令，xshell远程需要依赖服务器上的sshd这个服务</span><br><span class="line">    -   <span class="variable language_">window</span>/linux 的终端</span><br><span class="line">        -   ssh username@<span class="variable constant_">IP</span> 连接进目标机器</span><br><span class="line">        -   如果目标<span class="variable constant_">IP</span>端口改了通过 -p xxx 指定</span><br><span class="line">        -   ssh username@<span class="variable constant_">IP</span> <span class="string">&quot;free -m&quot;</span> 控制远程服务器发送 free -m 这条指令</span><br><span class="line">    -   <span class="string">`ssh-copy-id`</span></span><br><span class="line">        -   连接主机 <span class="string">`ssh-copy-id -i ./id_rsa.pub root@114.115.212.xxx`</span> 向目标主机<span class="number">114</span> 上传公钥, 就可以不需要密码直连</span><br><span class="line">-   <span class="string">`scp`</span>:命令用于 <span class="title class_">Linux</span> 之间复制文件和目录(全量完整复制，效率不太好)</span><br><span class="line">    -   scp -P <span class="number">22</span> 本机文件 root@对面<span class="attr">IP</span>:对面位置 =&gt; 文件上传</span><br><span class="line">    -   scp -r -P <span class="number">22</span> 本机文件夹 root@对面<span class="attr">IP</span>:对面位置 =&gt; 文件夹上传</span><br><span class="line">    -   scp -P <span class="number">22</span> root@对面<span class="attr">IP</span>:对面文件位置 本机位置 =&gt; 文件下载</span><br><span class="line">    -   scp -r -P <span class="number">22</span> root@对面<span class="attr">IP</span>:对面文件夹位置 本机位置 =&gt; 文件夹下载</span><br><span class="line">-   <span class="string">`rsync`</span>:增量的复制</span><br><span class="line">    -   不同于 cp 或 scp 的一点是，使用 rsync 命令备份数据时，不会直接覆盖以前的数据（如果数据已经存在），而是先判断已经存在的数据和新数据的差异，只有数据不同时才会把不相同的部分覆盖。</span><br><span class="line">    -   <span class="string">`rsync -av /etc/passwd 192.168.188.128:/tmp/1.txt`</span></span><br><span class="line">-   <span class="string">`wget`</span>:非常稳定，断点续传，支持ftp http等协议 下载网络资源</span><br><span class="line">    -   wget url：直接下载</span><br><span class="line">    -   wget -o path/name url：下载并改名</span><br><span class="line">    -   wget --limit-rate=1k url：限制下载速度</span><br><span class="line">    -   wget -c --limit-rate=1k 下到一半的url：断点续传</span><br><span class="line">    -   wget -b url：后台下载</span><br><span class="line">-   <span class="string">`telnet`</span>:用于登入远程主机，以及监测远程端口是否打开，采用名文传输，安全性低，后来被ssh取代</span><br><span class="line">    -   telnet <span class="number">111.111</span><span class="number">.111</span><span class="number">.111</span> <span class="number">8080</span></span><br><span class="line"></span><br><span class="line">-   <span class="string">`ping`</span>:<span class="string">`ping www.baidu.com -c 6 -i 0.6`</span> ,ping6次 间隔<span class="number">0.6</span>秒</span><br><span class="line">-   <span class="string">`curl url`</span>:获取网站源码</span><br><span class="line">    -   curl url &gt; xxx.<span class="property">html</span> 下载网页源码</span><br><span class="line">    -   curl -o xxx.<span class="property">html</span> 同样下载网页源码</span><br><span class="line">    -   curl -o /dev/<span class="literal">null</span> -s -w %&#123;http_code&#125; url 测试网页是否存活,返回状态码(echo $?测试是执行成功，<span class="number">0</span>就说明成功了)</span><br><span class="line">    -   curl -o /dev/<span class="literal">null</span> -s -c xxx.<span class="property">txt</span> url 获取指定网址提供的cookie保存到xxx中</span><br><span class="line">    -   curl -O xxxx.<span class="property">png</span> 直接下载文件</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h4 id="端口服务进程号配置查询"><a href="#端口服务进程号配置查询" class="headerlink" title="端口服务进程号配置查询"></a>端口服务进程号配置查询</h4><blockquote>
<p>服务器中端口需要开放才能访问</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">-   <span class="string">`ps`</span></span><br><span class="line">    -   <span class="string">`ps -aux|-af |grep &lt;server-name&gt;`</span></span><br><span class="line">-   <span class="string">`netstat`</span></span><br><span class="line">    -   <span class="string">`netstat -anp|grep 21`</span>:查询端口是否被使用</span><br><span class="line">    -   <span class="string">`netstat -antup|grep pid`</span>:根据 pid 查看端口使用者</span><br><span class="line">    -   <span class="string">`netstat -tlnp`</span>:查看监听的端口</span><br><span class="line">    -   <span class="string">`netstat -antp`</span>:查看系统网络服务</span><br><span class="line">-   <span class="string">`ss`</span></span><br><span class="line">-   <span class="string">`ip xxx`</span></span><br><span class="line">-   <span class="string">`lsof`</span>:需要安装</span><br><span class="line">    -   lsof abc.<span class="property">txt</span> 显示开启文件abc.<span class="property">txt</span>的进程</span><br><span class="line">    -   lsof -c abc 显示abc进程现在打开的文件</span><br><span class="line">    -   lsof -i :<span class="number">22</span>  查看<span class="number">22</span>端口现在运行什么程序</span><br><span class="line">-   <span class="string">`nslookup lzoxun.top`</span>：根据域名查询<span class="variable constant_">IP</span></span><br></pre></td></tr></table></figure>

<h3 id="xshell-中文设置"><a href="#xshell-中文设置" class="headerlink" title="xshell 中文设置"></a>xshell 中文设置</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">-   <span class="string">`echo $LANG`</span>:查看当前编码</span><br><span class="line">-   <span class="string">`locale`</span>:查看系统拥有的编码</span><br><span class="line">-   <span class="string">`yum groupinstall chinese-support`</span>:安装中文包</span><br><span class="line">-   <span class="string">`yum install -y langpacks-zh_CN`</span>:或安装这个</span><br><span class="line">-   <span class="string">`LANG=&quot;zh_CN.UTF-8&quot;`</span>:临时改成中文</span><br><span class="line">-   <span class="string">`yum-langpacks`</span>:语言包</span><br><span class="line">-   <span class="string">`/etc/locale.conf`</span>:centos7 语言配置文件</span><br><span class="line">-   <span class="regexp">/etc/</span>locale.<span class="property">gen</span> - 配置文件: <span class="string">`/etc/yum/pluginconf.d/langpacks.conf`</span></span><br></pre></td></tr></table></figure>

<h3 id="去除-centos-滴滴提示音"><a href="#去除-centos-滴滴提示音" class="headerlink" title="去除 centos 滴滴提示音"></a>去除 centos 滴滴提示音</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">1.执行</span></span><br><span class="line">vi /etc/inputrc</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将 <span class="comment">#set bell-style none 把这一行的#去掉</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">2、执行</span></span><br><span class="line">vim ~/.bashrc | /etc/profile</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">添加：setterm –blength 0</span></span><br><span class="line">3、执行：reboot</span><br></pre></td></tr></table></figure>

<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">-   新系统需要的一些设置</span><br><span class="line">    -   设置中文编码</span><br><span class="line">        -   echo <span class="variable constant_">LANG</span>=<span class="string">&quot;zh_CN.gbk&quot;</span> &gt;&gt; <span class="regexp">/etc/</span>locale.<span class="property">conf</span></span><br><span class="line">    -   开启网卡（最小化安装时没开的 不能使用 ifconfig 指令）</span><br><span class="line">        -   echo <span class="variable constant_">ONBOOT</span>=yes &gt;&gt; <span class="regexp">/etc/</span>sysconfig/network-scripts/ifcfg-ens33</span><br></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://www.bt.cn/">管理平台-宝塔</a></p>
<ul>
<li><code>bt default</code>:获取密码<br><a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1uZ4y1u7Ca?p=104&spm_id_from=pageDriver">课程 1</a><br><a target="_blank" rel="noopener" href="https://distrowatch.com/dwres.php?resource=popularity">发行版排行</a><br><a target="_blank" rel="noopener" href="https://www.deepin.org/zh/">国内 deepin</a><br><a target="_blank" rel="noopener" href="https://www.ubuntukylin.com/downloads/">国内优麒麟</a><br><a target="_blank" rel="noopener" href="https://mirrors.tuna.tsinghua.edu.cn/osdn/storage/g/m/ma/manjaro/xfce/21.0-pre1/">manjaro</a><br><a target="_blank" rel="noopener" href="https://mirrors.tuna.tsinghua.edu.cn/">清华大学开源软件镜像站</a><br><a target="_blank" rel="noopener" href="https://wiki.archlinux.org/">archlinux</a></li>
</ul>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="http://example.com">lzoxun</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://example.com/2023/07/22/linux/linux/">http://example.com/2023/07/22/linux/linux/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://example.com" target="_blank">学习笔记</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2023/07/22/other/other-algorithm/" title="数据结构与算法"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">数据结构与算法</div></div></a></div><div class="next-post pull-right"><a href="/2023/07/22/linux/linux-servers-yule/" title="工具"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">工具</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">lzoxun</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">108</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/liaozhongxun"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/liaozhongxun" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:869664233@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">这是我的文档</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9F%BA%E7%A1%80%E7%AE%80%E4%BB%8B"><span class="toc-number">1.</span> <span class="toc-text">基础简介</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%B3%BB%E7%BB%9F"><span class="toc-number">1.1.</span> <span class="toc-text">系统</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8C%87%E4%BB%A4"><span class="toc-number">2.</span> <span class="toc-text">指令</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C%E5%91%BD%E4%BB%A4"><span class="toc-number">2.1.</span> <span class="toc-text">基本操作命令</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9C"><span class="toc-number">2.2.</span> <span class="toc-text">文件操作</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E5%86%85%E5%AE%B9%E6%93%8D%E4%BD%9C"><span class="toc-number">2.3.</span> <span class="toc-text">文件内容操作</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B8%B8%E7%94%A8%E6%A8%A1%E5%9D%97"><span class="toc-number">2.4.</span> <span class="toc-text">常用模块</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9F%BA%E6%9C%AC%E7%B3%BB%E7%BB%9F%E8%BF%90%E7%94%A8%E6%8C%87%E4%BB%A4"><span class="toc-number">2.5.</span> <span class="toc-text">基本系统运用指令</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AD%97%E7%AC%A6"><span class="toc-number">2.6.</span> <span class="toc-text">字符</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86"><span class="toc-number">3.</span> <span class="toc-text">系统管理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%94%A8%E6%88%B7%E3%80%81%E7%BB%84"><span class="toc-number">3.1.</span> <span class="toc-text">用户、组</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E7%9A%84%E6%9D%83%E9%99%90%E4%B8%8E%E5%BD%92%E5%B1%9E"><span class="toc-number">3.2.</span> <span class="toc-text">文件的权限与归属</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B6%E4%BB%96%E7%89%B9%E6%AE%8A%E6%9D%83%E9%99%90-%EF%BC%88%E6%9A%82%E6%97%B6%E8%B7%B3%E8%BF%87-%E8%AF%BE%E7%A8%8B-1-66-75-%EF%BC%89"><span class="toc-number">3.3.</span> <span class="toc-text">其他特殊权限 （暂时跳过 课程 1 66~75 ）</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%96%87%E4%BB%B6"><span class="toc-number">4.</span> <span class="toc-text">文件</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E8%AF%A6%E6%83%85"><span class="toc-number">4.1.</span> <span class="toc-text">文件详情</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E5%BD%95%E4%BF%A1%E6%81%AF"><span class="toc-number">4.2.</span> <span class="toc-text">目录信息</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#vi-%E4%B8%8E-vim"><span class="toc-number">5.</span> <span class="toc-text">vi 与 vim</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%A3%81%E7%9B%98%E7%AE%A1%E7%90%86%E4%B8%8E%E6%96%87%E4%BB%B6%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F"><span class="toc-number">6.</span> <span class="toc-text">磁盘管理与文件管理系统</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%A3%81%E7%9B%98%E5%88%86%E5%8C%BA%E4%B8%8E%E6%A0%BC%E5%BC%8F%E5%8C%96"><span class="toc-number">6.1.</span> <span class="toc-text">磁盘分区与格式化</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#quota-%E7%A3%81%E7%9B%98%E9%85%8D%E9%A2%9D"><span class="toc-number">6.2.</span> <span class="toc-text">quota 磁盘配额</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#RAID-%E7%A3%81%E7%9B%98%E9%98%B5%E5%88%97%EF%BC%88%E6%9A%82%E6%97%B6%E8%B7%B3%E8%BF%87-%E8%AF%BE%E7%A8%8B-1-92-104-%EF%BC%89"><span class="toc-number">6.3.</span> <span class="toc-text">RAID 磁盘阵列（暂时跳过 课程 1 92~104 ）</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85"><span class="toc-number">7.</span> <span class="toc-text">软件安装</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%A2%84%E5%A4%87%E7%9F%A5%E8%AF%86"><span class="toc-number">7.1.</span> <span class="toc-text">预备知识</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%BA%90%E7%A0%81%E5%AE%89%E8%A3%85"><span class="toc-number">7.2.</span> <span class="toc-text">源码安装</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#rpm-RedHat-Packet-Manager"><span class="toc-number">7.3.</span> <span class="toc-text">rpm(RedHat Packet Manager)</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#yum-%E5%AE%89%E8%A3%85"><span class="toc-number">7.4.</span> <span class="toc-text">yum 安装</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#DNF-%E6%96%B0%E7%9A%84-yum"><span class="toc-number">7.5.</span> <span class="toc-text">DNF (新的 yum)</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%BF%9B%E7%A8%8B%E4%B8%8E%E6%9C%8D%E5%8A%A1%E7%AE%A1%E7%90%86"><span class="toc-number">8.</span> <span class="toc-text">进程与服务管理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BF%9B%E7%A8%8B%EF%BC%88PID%EF%BC%89"><span class="toc-number">8.1.</span> <span class="toc-text">进程（PID）</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9C%8D%E5%8A%A1"><span class="toc-number">8.2.</span> <span class="toc-text">服务</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BF%90%E8%A1%8C%E7%BA%A7%E5%88%AB%EF%BC%88%E7%9B%AE%E6%A0%87%EF%BC%89"><span class="toc-number">8.3.</span> <span class="toc-text">运行级别（目标）</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%A1%E5%88%92%E4%BB%BB%E5%8A%A1-%E4%BB%8E%E6%9C%AA%E8%AE%BE%E7%BD%AE%E6%88%90%E5%8A%9F"><span class="toc-number">8.4.</span> <span class="toc-text">计划任务(从未设置成功)</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="toc-number">9.</span> <span class="toc-text">配置文件</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#bashrc"><span class="toc-number">9.1.</span> <span class="toc-text">.bashrc</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%85%B6%E4%BB%96"><span class="toc-number">10.</span> <span class="toc-text">其他</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8F%90%E5%8D%87%E6%95%88%E7%8E%87"><span class="toc-number">10.1.</span> <span class="toc-text">提升效率</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%8D%E9%87%8D%E8%A6%81"><span class="toc-number">10.2.</span> <span class="toc-text">不重要</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E7%B3%BB%E7%BB%9F%E4%BF%A1%E6%81%AF"><span class="toc-number">10.3.</span> <span class="toc-text">查看系统信息</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%8D%E5%B8%B8%E7%94%A8"><span class="toc-number">10.4.</span> <span class="toc-text">不常用</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BD%91%E7%BB%9C%E7%9B%B8%E5%85%B3"><span class="toc-number">10.5.</span> <span class="toc-text">网络相关</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9%E7%BD%91%E7%BB%9C%E4%BF%A1%E6%81%AF"><span class="toc-number">10.6.</span> <span class="toc-text">修改网络信息</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BD%91%E7%BB%9C%E5%91%BD%E4%BB%A4"><span class="toc-number">10.7.</span> <span class="toc-text">网络命令</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E7%AB%AF%E5%8F%A3%E6%9C%8D%E5%8A%A1%E8%BF%9B%E7%A8%8B%E5%8F%B7%E9%85%8D%E7%BD%AE%E6%9F%A5%E8%AF%A2"><span class="toc-number">10.7.1.</span> <span class="toc-text">端口服务进程号配置查询</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#xshell-%E4%B8%AD%E6%96%87%E8%AE%BE%E7%BD%AE"><span class="toc-number">10.8.</span> <span class="toc-text">xshell 中文设置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8E%BB%E9%99%A4-centos-%E6%BB%B4%E6%BB%B4%E6%8F%90%E7%A4%BA%E9%9F%B3"><span class="toc-number">10.9.</span> <span class="toc-text">去除 centos 滴滴提示音</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-11/" title="win 11 set">win 11 set</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-gitbash/" title="git bash">git bash</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-wsl/" title="wsl">wsl</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-main/" title="window">window</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/web/%E5%85%BC%E5%AE%B9%E9%97%AE%E9%A2%98/" title="兼容问题">兼容问题</a><time datetime="2023-07-22T07:14:09.699Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By lzoxun</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (false){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><div class="js-pjax"></div><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-nest.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div class="no-result" id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"log":false,"model":{"jsonPath":"/live2dw/assets/haruto.model.json"},"display":{"position":"right","width":100,"height":200,"right":300},"mobile":{"show":true}});</script></body></html>